n = int(input()) S = input() mod = 998244353 dp = [0]*(26**2) if len(S) == 1: if S == "?": ans = 26 else: ans = 1 print(ans) exit() if S[0] == "?": if S[1] == "?": for i in range(26): for j in range(26): if i == j: continue dp[i*26+j] += 1 else: c = ord(S[1])-ord("a") for i in range(26): if i == c: continue dp[i*26+c] += 1 else: c = ord(S[0])-ord("a") if S[1] == "?": for j in range(26): if c == j: continue dp[c*26+j] += 1 else: c2 = ord(S[1])-ord("a") if c != c2: dp[c*26+c2] += 1 for s in S[2:]: ndp = [0]*(26**2) if s == "?": for i in range(26**2): if dp[i] == 0: continue x,y = divmod(i,26) for j in range(26): if y == j or x == j: continue ndp[y*26+j] += dp[i] ndp[y*26+j] %= mod else: c = ord(s)-ord("a") for i in range(26**2): if dp[i] == 0: continue x,y = divmod(i,26) if x == c or y == c: continue ndp[y*26+c] += dp[i] ndp[y*26+c] %= mod dp = ndp print(sum(dp)%mod)