using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var s = ReadLine(); WriteLine(Count010(s)); } static long Count010(string s) { var mod = 998_244_353; var dp = new long[3][]; for (var i = 0; i < dp.Length; ++i) dp[i] = new long[s.Length]; var count = new long[s.Length]; count[0] = s[0] == '?' ? 2 : 1; if (s[0] != '1') dp[0][0] = 1; for (var i = 1; i < s.Length; ++i) { if (s[i] == '0') { dp[0][i] = (dp[0][i - 1] + count[i - 1]) % mod; dp[1][i] = dp[1][i - 1]; dp[2][i] = (dp[2][i - 1] + dp[1][i - 1]) % mod; count[i] = count[i - 1]; } else if (s[i] == '1') { dp[0][i] = dp[0][i - 1]; dp[1][i] = (dp[1][i - 1] + dp[0][i - 1]) % mod; dp[2][i] = dp[2][i - 1]; count[i] = count[i - 1]; } else { dp[0][i] = (dp[0][i - 1] * 2 + count[i - 1]) % mod; dp[1][i] = (dp[1][i - 1] * 2 + dp[0][i - 1]) % mod; dp[2][i] = (dp[2][i - 1] * 2 + dp[1][i - 1]) % mod; count[i] = count[i - 1] * 2 % mod; } } return dp[2].Last(); } }