#include using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; string S; cin >> N >> S; if(N == 1 && S == "?"){ cout << 26 << "\n"; return 0; }else if(N == 1){ cout << 1 << "\n"; return 0; } long long mod = 998244353; long long dp[50010][680] = {}; long long ikkomae[50010][26] = {}; for(int i = 0; i < 676; i++){ char c1 = 'a' + (i / 26); char c2 = 'a' + (i % 26); if(c1 == c2) continue; if(S[0] != '?' && S[0] != c1) continue; if(S[1] != '?' && S[1] != c2) continue; dp[1][i] = 1; ikkomae[1][i % 26] ++; } for(int i = 2; i < N; i++){ for(int j = 0; j < 676; j++){ char c1 = 'a' + (j / 26); char c2 = 'a' + (j % 26); if(c1 == c2) continue; if(S[i] != '?' && S[i] != c2) continue; dp[i][j] = (mod + ikkomae[i-1][j/26] - dp[i-1][26*(j%26)+j/26]) % mod; ikkomae[i][j%26] += dp[i][j]; ikkomae[i][j%26] %= mod; } } long long ans = 0; for(int i = 0; i < 676; i++) ans += dp[N-1][i]; cout << ans % mod << "\n"; }