n=int(input()) s=input() M=998244353 q=[[0]*27 for i in range(27)] q[-1][-1]=1 for c in s: nq=[[0]*27 for i in range(27)] for i1 in range(27): y=sum(q[i1])%M for i3 in range(26): if i3!=i1: if c==chr(i3+ord("a")) or c=="?": nq[i3][i1]=(y-q[i1][i3])%M q=nq print(sum(sum(q[i]) for i in range(27))%M)