n = int(input()) s = input() mod = 998244353 dp = [[0]*2 for _ in range(2)] dp[0][0] = 1 for c in s: nxt = [[0]*2 for _ in range(2)] for i in range(2): for j in range(2): for k in range(26): if i==0 and ord(c)-ord('a') < k: continue if j==1 and k==0: continue nxt[i or ord(c)-ord('a')>k][j or k==0] += dp[i][j]%mod dp = nxt print(dp[1][1]%mod)