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: dp[1][code(S[0])][code(S[1])] = 1 for i in range(2,N): if S[i] == "?": for j in range(26): for k in range(26): for l in range(26): if j != l and k != l: dp[i][k][l] = (dp[i][k][l] + dp[i-1][j][k]) % 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)