N = int(input()) S = input() mod = 998244353 DP = [[[0] * 26 for _ in range(26)] for _ in range(N+1)] DP[0][0][0]=1 for n in range(N): if S[n]=='?': TEMP = [0]*26 for i in range(26): for j in range(26): TEMP[j]+=DP[n][j][i] for j in range(26): for k in range(26): if j!=k: DP[n+1][k][j]=(TEMP[j]-DP[n][j][k])%mod if j==0 and k==0 and n==0: DP[1][0][0]=1 else: k = ord(S[n])-97 for i in range(26): for j in range(26): if (i!=k or n<=1) and (j!=k or n==0): DP[n+1][k][j]=(DP[n+1][k][j]+DP[n][j][i])%mod ans = 0 for i in range(26): for j in range(26): ans += DP[N][i][j] print(ans%mod)