mod = 998244353 N = int(input()) S = input() dp = [[0 for _ in range(3)] for _ in range(N + 1)] dp[0][0] = 1 for i in range(N): for k in range(10): if (i != 0) & (S[i] == '?' or k == int(S[i])): dp[i + 1][k % 3] += 1 dp[i + 1][k % 3] %= mod for j in range(3): if S[i] == '?' or k == int(S[i]): dp[i + 1][(k + j) % 3] += dp[i][j] dp[i + 1][(k + j) % 3] %= mod ans = 0 for i in range(1, N + 1): ans += dp[i][0] ans %= mod print(ans)