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 base = [0]*26 for s in S[2:]: nbase = [0]*26 ndp = [0]*(26**2) if s == "?": for i in range(26**2): x,y = divmod(i,26) dp[i] += base[x] nbase[y] += dp[i] nbase[y] %= mod ndp[y*26+y] -= dp[i] ndp[y*26+y] %= mod ndp[y*26+x] -= dp[i] ndp[y*26+x] %= mod else: c = ord(s)-ord("a") for i in range(26**2): x,y = divmod(i,26) dp[i] += base[x] if x == c or y == c: continue ndp[y*26+c] += dp[i] ndp[y*26+c] %= mod dp = ndp base = nbase ans = 0 for i in range(26): for j in range(26): ans += dp[i*26+j]+base[i] ans %= mod print(ans)