import sys INF = float('inf') #10**20,2**63,float('inf') MOD = 10**9 + 7 MOD2 = 998244353 #from collections import defaultdict def solve(): def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LC(): return list(input()) def IC(): return [int(c) for c in input()] def MI(): return map(int, sys.stdin.readline().split()) N = II() S = LC() Alpha = {} for i in range(97, 123): Alpha[chr(i)] = i - 97 Alpha[i-97] = chr(i) DP = [[[0]*26 for _ in range(26)] for _ in range(N+10)] if S[0] == "?": for i in range(26): DP[1][0][i] = 1 else: DP[1][0][Alpha[S[0]]] = 1 if N == 1: print(sum(DP[1][0])) exit() if S[1] == "?": for i in range(26): for j in range(26): if i == j:continue DP[2][i][j] += DP[1][0][i] else: for i in range(26): if i == Alpha[S[1]]:continue DP[2][i][Alpha[S[1]]] += DP[1][0][i] if N == 2: Ans = 0 for i in range(26): Ans += sum(DP[2][i]) print(Ans) exit() for n in range(2,N): for i in range(26): for j in range(26): if S[n] == "?": for k in range(26): if i == k or j == k:continue DP[n + 1][j][k] += DP[n][i][j] DP[n + 1][j][k] %= MOD2 else: if i == Alpha[S[n]] or j == Alpha[S[n]]:continue DP[n+1][j][Alpha[S[n]]] += DP[n][i][j] DP[n + 1][j][Alpha[S[n]]] %= MOD2 #print(DP[n+1]) Ans = 0 for i in range(26): for j in range(26): Ans += DP[N][i][j] Ans %= MOD2 print(Ans % MOD2) return solve() #sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!