Problem A. Magic Box
单点时限:1000ms
内存限制:256MB
The circus clown Sunny has a magic box. When the circus is performing, Sunny
puts some balls into the box one by one. The balls are in three colors:
red(R), yellow(Y) and blue(B). Let Cr, Cy, Cb denote the numbers of red,
yellow, blue balls in the box. Whenever the differences among Cr, Cy, Cb
happen to be x, y, z, all balls in the box vanish. Given x, y, z and the
sequence in which Sunny put the balls, you are to find what is the maximum
number of balls in the box ever.
输入
Line 1: x y z
Line 2: the sequence consisting of only three characters ‘R’, ‘Y’ and ‘B’.
For 30% data, the length of the sequence is no more than 200.
The maximum number of balls in the box ever.
Another Sample
样例输入