M = int(input()) N = input() now, mod = 1, 998244353 ans = 0 mul = 1 F = [] for i in range(len(N)): t = ord(N[len(N)-i-1])-ord('0') #t, t+10, ... < M x = ((M-1)-t)//10 cnt = x+1 first = t last = first + (cnt-1) * 10 # print(first, last, cnt) s = (first + last) * cnt // 2 F.append((s*now, cnt)) now = now * M % mod S = [] nnow = 1 for i in range(len(N)): S.append(nnow) nnow *= F[i][1] nnow %= mod nnow = 1 for i in reversed(range(len(N))): ans += F[i][0] * nnow * S[i] ans %= mod nnow *= F[i][1] print(ans)