intmaxLen(string seq, int x, int y, int z){ int max = 0; int len = 0; int r = 0, g = 0, b = 0; for (int i = 0; i < seq.size(); i++) { if (seq[i] == 'R') r++; elseif (seq[i] == 'B') g++; elseif (seq[i] == 'Y') b++; len++; if ((abs(r - g) == x && abs(g - b) == y && abs(b - r) == z) || (abs(r - g) == x && abs(b - r) == y && abs(g - b) == z) || (abs(g - b) == x && abs(r - g) == y && abs(b - r) == z) || (abs(g - b) == x && abs(b - r) == y && abs(r - g) == z) || (abs(b - r) == x && abs(g - b) == y && abs(r - g) == z) || (abs(b - r) == x && abs(r - g) == y && abs(g - b) == z)) { r = 0; g = 0; b = 0; if (max < len) max = len; len = 0; } }
if (max < len) max = len;
return max; }
intmain(){ int x = 0, y = 0, z = 0; string charSeq; cin >> x >> y >> z; cin >> charSeq; cout << maxLen(charSeq, x, y, z); }