#include #include #include using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ull M = 998244353; vector F,I,iF; ull powm(ull a,ull i){ if(i==0) return 1; ull res = powm(a*a%M,i/2); if(i%2==1) res = res * a % M; return res; } void initComb(int Z){ F.resize(Z+1); F[0]=1; for(int i=1; i<=Z; i++) F[i]=F[i-1]*i%M; I.resize(Z+1); I[1]=1; for(int i=2; i<=Z; i++) I[i]=M-M/i*I[M%i]%M; iF.resize(Z+1); iF[0]=1; for(int i=1; i<=Z; i++) iF[i]=iF[i-1]*I[i]%M; } ull Comb(int n,int r){ return F[n]*iF[r]%M*iF[n-r]%M; } int main(){ int N; string S; cin >> N >> S; string chs = "ABC"; vector Cchs(chs.size(),0); for(char c:S) rep(t,chs.size()) if(chs[t]==c) Cchs[t]++; for(char c:chs) if(S.find(c)==string::npos){ cout<<"1\n"; return 0; } { auto p = S.find("AC"); if(p != string::npos){ S = S.substr(p+1) + S.substr(0,p+1); } } bool fixed = true; rep(i,S.size()-1) if(S[i]