#include using namespace std; template struct modint{ long long val; modint(): val(0) {} modint(long long x){ if(x < 0) val = x % MOD + MOD; else val = x % MOD; } modint(const modint &t){ val = t.val; } modint& operator =(const modint m){ val = m.val; return *this; } modint operator -(){ return modint(-val); } modint& operator-=(const modint &m){ val -= m.val; if(val < 0) val += MOD; return *this; } modint& operator+=(const modint &m){ val += m.val; if(val >= MOD) val -= MOD; return *this; } modint& operator*=(const modint &m){ val *= m.val; val %= MOD; return *this; } modint& operator/=(modint m){ *this *= m.inv(); return *this; } modint inv(){ long long x = 1, y = 0; long long a = val, b = MOD; while(b != 0){ long long t = a / b; a -= t * b; x -= t * y; swap(a, b); swap(x, y); } x %= MOD; if(x < 0) x += MOD; return modint(x); } modint pow(long long k){ long long res = 1; long long v = val; while(k > 0){ if(k & 1) res = res * v % MOD; v = v * v % MOD; k >>= 1; } return modint(res); } bool operator==(const modint &m){ return val == m.val; } modint operator+(const modint &m){ return modint(*this) += m; } modint operator-(const modint &m){ return modint(*this) -= m; } modint operator*(const modint &m){ return modint(*this) *= m; } modint operator/(const modint &m){ return modint(*this) /= m; } bool operator!=(const modint &m){ return modint(*this).val != m.val; } bool operator!=(const int &m){ return modint(*this).val != m; } }; const int MOD = 998244353; using mint = modint; int main(){ int N; cin >> N; string S; cin >> S; if(N == 1){ if(S[0] == '?') cout << 26 << endl; else cout << 1 << endl; return 0; } vector>> dp(N, vector>(26, vector(26))); if(S[0] == '?'){ if(S[1] == '?'){ for(int i = 0; i < 26; i++){ for(int j = 0; j < 26; j++){ if(i == j) continue; dp[1][i][j] = 1; } } } else{ for(int i = 0; i < 26; i++){ if(i == S[1] - 'a') continue; dp[1][S[1] - 'a'][i] = 1; } } } else{ if(S[1] == '?'){ for(int i = 0; i < 26; i++){ if(i == S[0] - 'a') continue; dp[1][i][S[0] - 'a'] = 1; } } else{ dp[1][S[1] - 'a'][S[0] - 'a'] = 1; } } for(int i = 2; i < N; i++){ if(S[i] == '?'){ for(int j = 0; j < 26; j++){ mint temp = 0; for(int k = 0; k < 26; k++) { if(j == k) continue; temp += dp[i - 1][j][k]; } for(int k = 0; k < 26; k++){ if(j == k) continue; dp[i][k][j] += temp - dp[i - 1][j][k]; } } } else{ int id = S[i] - 'a'; for(int j = 0; j < 26; j++){ if(id == j) continue; mint temp = 0; for(int k = 0; k < 26; k++){ if(k == id) continue; temp += dp[i - 1][j][k]; } dp[i][id][j] += temp; } } } mint ans = 0; for(int i = 0; i < 26; i++){ for(int j = 0; j < 26; j++){ ans += dp[N - 1][i][j]; } } cout << ans.val << endl; }