## https://yukicoder.me/problems/no/2019 MOD = 998244353 def main(): N = int(input()) S = input() answer = 0 dp = [0] * 3 for s in S: new_dp = [0] * 3 for x in range(3): y = (x * 10) % 3 if s == "?": for z in range(10): yz = (y + z) % 3 new_dp[yz] += dp[x] new_dp[yz] %= MOD else: yz = (y + int(s)) % 3 new_dp[yz] += dp[x] new_dp[yz] %= MOD if s == "?": for z in range(10): new_dp[z % 3] += 1 new_dp[z % 3] %= MOD else: new_dp[int(s) % 3] += 1 new_dp[int(s) % 3] %= MOD dp = new_dp answer += dp[0] answer %= MOD print(answer) if __name__ == "__main__": main()