import sys input = sys.stdin.readline N = int(input()) S = list(input())[: -1] mod = 998244353 dp = [[0] * 26 for _ in range(26)] if N == 1: if S[0] == "?": print(26) else: print(0) exit(0) for x in range(26): for y in range(26): if x == y: continue cx = chr(ord("a") + x) cy = chr(ord("a") + y) if S[0] == cx and S[1] == cy: dp[x][y] += 1 if S[0] == "?" and S[1] == cy: dp[x][y] += 1 if S[0] == cx and S[1] == "?": dp[x][y] += 1 if S[0] == "?" and S[1] == "?": dp[x][y] += 1 #print(dp) for c in S[2: ]: z = ord(c) - ord("a") dp2 = [[0] * 26 for _ in range(26)] if c != "?": for x in range(26): for y in range(26): cx = chr(ord("a") + x) cy = chr(ord("a") + y) if x != z and y != z: dp2[y][z] += dp[x][y] dp2[y][z] %= mod else: sm = [0] * 26 for x in range(26): for y in range(26): cx = chr(ord("a") + x) cy = chr(ord("a") + y) dp2[y][y] -= dp[x][y] dp2[y][y] %= mod dp2[y][x] -= dp[x][y] dp2[y][y] %= mod sm[y] += dp[x][y] sm[y] %= mod for x in range(26): for y in range(26): dp2[x][y] += sm[x] dp2[x][y] %= mod dp = [t[: ] for t in dp2] res = 0 for x in range(26): for y in range(26): res += dp[x][y] res %= mod print(res)