import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 10**16 md = 998244353 # md = 10**9+7 n = II() s = SI() if n == 1: if s[0] == "?": print(26) else: print(1) exit() for i in range(n-1): if s[i] != "?" and s[i] == s[i+1]: print(0) exit() for i in range(n-2): if s[i] != "?" and s[i] == s[i+2]: print(0) exit() dp = [0]*26*26 col = [0]*26 if s[0] == "?" and s[1] == "?": for i in range(26): for j in range(26): if i == j: continue dp[i*26+j] = 1 col[j] += 1 elif s[0] == "?": j = ord(s[1])-97 for i in range(26): if i == j: continue dp[i*26+j] = 1 col[j] += 1 elif s[1] == "?": i = ord(s[0])-97 for j in range(26): if i == j: continue dp[i*26+j] = 1 col[j] += 1 else: i = ord(s[0])-97 j = ord(s[1])-97 dp[i*26+j] = 1 col[j] += 1 for c in s[2:]: a = ord(c)-97 ndp = [0]*26*26 ncl = [0]*26 for i in range(26): for j in range(26): if i == j: continue if c == "?" or j == a: val = (col[i]-dp[j*26+i])%md ndp[i*26+j] = val ncl[j] += val dp = ndp col = ncl ans = 0 for i in range(26): for j in range(26): ans += dp[i*26+j] ans %= md print(ans)