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