n = int(input()) s = input() mod = 998244353 dp = [[0] * 27 for _ in range(27)] dp[-1][-1] = 1 for i in s: if i == "?": i_sum = [sum(dp[j][i] for j in range(27)) for i in range(27)] dp2 = [[0 if i == j or j == 26 else (i_sum[i] - dp[j][i]) % mod for j in range(27)]for i in range(27)] else: char = ord(i) - ord("a") dp2 = [[0] * 27 for _ in range(27)] for j in range(27): if j == char: continue dp2[j][char] = sum(dp[i][j] for i in range(27) if i != char) % mod dp = dp2 print(sum(map(sum, dp)) % mod)