#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include using mint = atcoder::modint998244353; int main() { fast_io(); int n; string s; cin >> n >> s; vector dp(n + 1, vector(27, vector(27))); dp[0][26][26] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < 27; j++) { for (int k = 0; k < 27; k++) { for (int l = 0; l < 26; l++) { if (j == l || k == l) { continue; } if (s[i] == '?' || s[i] == 'a' + l) { dp[i + 1][k][l] += dp[i][j][k]; } } } } } mint ans = 0; for (int i = 0; i < 27; i++) { for (int j = 0; j < 27; j++) { ans += dp[n][i][j]; } } cout << ans.val() << endl; }