#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; mint dp[27][27], ndp[27][27]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; dp[26][26] = 1; for(char si: s) { rep(i, 27) rep(j, 27) ndp[i][j] = 0; for(char c = 'a'; c <= 'z'; c++) if (si == c || si == '?') { int x = c - 'a'; rep(i, 27) rep(j, 27) if (i != x && j != x) { ndp[j][x] += dp[i][j]; } } rep(i, 27) rep(j, 27) dp[i][j] = ndp[i][j]; } mint ans; rep(i, 27) rep(j, 27) ans += dp[i][j]; cout << ans.val() << endl; }