using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var s = ReadLine(); if (n == 1) { if (s[0] == '?') WriteLine(26); else WriteLine(1); return; } if (n == 2) { if (s[0] == '?' && s[1] == '?') WriteLine(26 * 25); else if (s[0] == '?' || s[1] == '?') WriteLine(25); else if (s[0] == s[1]) WriteLine(0); else WriteLine(1); return; } var dp = new long[26 * 26]; for (var i = 0; i < 26; ++i) for (var j = 0; j < 26; ++j) { if (i == j) continue; if ((s[0] == '?' || s[0] - 'a' == i) && (s[1] == '?' || s[1] - 'a' == j)) dp[i * 26 + j] = 1; } var mod = 998_244_353; for (var i = 2; i < n; ++i) { var ndp = new long[dp.Length]; for (var j = 0; j < dp.Length; ++j) { var x = j / 26; var y = j % 26; for (var z = 0; z < 26; ++z) { if (x == z || y == z) continue; if (s[i] == '?' || s[i] - 'a' == z) ndp[y * 26 + z] = (ndp[y * 26 + z] + dp[j]) % mod; } } dp = ndp; } WriteLine(dp.Sum() % mod); } }