import sys N = int(input()) S = input() mod = 998244353 dp = [[[0] * 26 for i in range(26)] for j in range(N)] def code(s): return ord(s) - 97 if N == 1: if S[0] == "?": print(26) sys.exit() else: print(1) sys.exit() if S[0:2] == "??": for i in range(26): for j in range(26): if i != j: dp[1][i][j] = 1 elif S[0] == "?": j = code(S[1]) for i in range(26): if i != j: dp[1][i][j] = 1 elif S[1] == "?": j = code(S[0]) for i in range(26): if i != j: dp[1][j][i] = 1 else: if S[0] != S[1]: dp[1][code(S[0])][code(S[1])] = 1 for i in range(2,N): if S[i] == "?": AS = [[0] * 27 for _ in range(26)] for k in range(26): for j in range(26): AS[k][j+1] = AS[k][j] + dp[i-1][j][k] for k in range(26): for l in range(26): if k != l: temp = AS[k][l] + AS[k][-1] - AS[k][l+1] dp[i][k][l] = temp % mod else: x = code(S[i]) for j in range(26): for k in range(26): if j != x and k != x: dp[i][k][x] = (dp[i][k][x] + dp[i-1][j][k]) % mod ans = 0 for i in range(26): ans = (ans + sum(dp[-1][i])) % mod print(ans)