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): for i in range(26): for j in range(26): for k in range(26): if (i!=k or n<=1) and (j!=k or n==0) and (S[n]=='?' or ord(S[n])-97==k): 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)