#include "testlib.h"
#include <string>
using namespace std;

int main(int argc, char* argv[]) {
    setName("ARC229 A checker");
    registerTestlibCmd(argc, argv);

    int X = inf.readInt();          // 读取输入中的 X
    string S = ouf.readToken();     // 读取选手输出的字符串

    int n = S.size();
    if (n < 1 || n > 100) {
        quitf(_wa, "Length %d out of range [1, 100]", n);
    }
    for (char c : S) {
        if (!isupper(c)) {
            quitf(_wa, "Character '%c' is not an uppercase letter", c);
        }
    }

    // 贪心模拟：每次替换最左边的 "ARC" 为 "CRA"
    int cnt = 0;
    while (true) {
        size_t pos = S.find("ARC");
        if (pos == string::npos) break;
        S.replace(pos, 3, "CRA");
        ++cnt;
    }

    if (cnt == X) {
        quitf(_ok, "f(S) = %d, matches X", cnt);
    } else {
        quitf(_wa, "f(S) = %d, expected %d", cnt, X);
    }
    return 0;
}
