import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] s = sc.next().toCharArray(); sc.close(); if (n == 1) { if (s[0] == '?') { System.out.println(26); } else { System.out.println(1); } return; } int mod = 998244353; long[][][] dp = new long[n][26][26]; for (int j1 = 0; j1 < 26; j1++) { if (s[0] != '?' && s[0] - 'a' != j1) { continue; } for (int j2 = 0; j2 < 26; j2++) { if (s[1] != '?' && s[1] - 'a' != j2) { continue; } if (j1 == j2) { continue; } dp[1][j1][j2] = 1; } } for (int i = 2; i < n; i++) { for (int c = 0; c < 26; c++) { if (s[i] != '?' && s[i] - 'a' != c) { continue; } for (int j1 = 0; j1 < 26; j1++) { if (j1 == c) { continue; } if (s[i - 1] != '?' && s[i - 1] - 'a' != j1) { continue; } for (int j2 = 0; j2 < 26; j2++) { if (j2 == c) { continue; } if (s[i - 2] != '?' && s[i - 2] - 'a' != j2) { continue; } dp[i][j1][c] += dp[i - 1][j2][j1]; } } } for (int j1 = 0; j1 < 26; j1++) { for (int j2 = 0; j2 < 26; j2++) { dp[i][j1][j2] %= mod; } } } long ans = 0; for (int j1 = 0; j1 < 26; j1++) { if (s[n - 1] == '?') { for (int j2 = 0; j2 < 26; j2++) { ans += dp[n - 1][j1][j2]; } } else { ans += dp[n - 1][j1][s[n - 1] - 'a']; } } ans %= mod; System.out.println(ans); } }