from _collections import defaultdict n=int(input()) s=["#"]+list(input()) al=list("abcdefghijklmnopqrstuvwxyz") dp=[defaultdict(int) for i in range(n+1)] mod=998244353 dp[0][".","#"]=1 for i in range(n): for x,y in dp[i]: dp[i][x,y]%=mod if s[i+1]!="?": if s[i+1]==y or s[i+1]==x:continue dp[i+1][y,s[i+1]]+=dp[i][x,y] dp[i + 1][y, s[i + 1]]%=mod else: for z in al: if z!=x and z!=y: dp[i+1][y,z]+=dp[i][x,y] dp[i+1][y,z]%=mod ans=0 for key in dp[n]: ans+=dp[n][key] ans%=mod print(ans)