#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n); i >= 0; i--) #define all(v) v.begin(), v.end() #define mod1 1000000007 #define mod2 998244353 typedef long long ll; ll my_pow(ll x, ll n, ll mod){ // 繰り返し二乗法.x^nをmodで割った余り. ll ret; if (n == 0){ ret = 1; } else if (n % 2 == 1){ ret = (x * my_pow((x * x) % mod, n / 2, mod)) % mod; } else{ ret = my_pow((x * x) % mod, n / 2, mod); } return ret; } int main(){ int N; cin >> N; string S; cin >> S; ll ab = 0; ll cd = 0; vector factorial(300005, 0); factorial[0] = 1; for (ll i = 0; i < 300004; i++){ factorial[i + 1] = (factorial[i] * (i + 1)) % mod2; } for (int i = 0; i < N; i++){ if (S[i] == 'A' || S[i] == 'B'){ ab++; } else{ cd++; } } ll ans = 1; ans = (ans * factorial[N]) % mod2; ans = (ans * my_pow(factorial[ab], mod2 - 2, mod2)) % mod2; ans = (ans * my_pow(factorial[cd], mod2 - 2, mod2)) % mod2; cout << ans << endl; }