using System; using System.Linq; using System.Collections.Generic; class Scanner { readonly Func parse; readonly char[] separator = new[] { ' ' }; private readonly Queue buffer = new Queue(); public Scanner(Func parse) { this.parse = parse; } public T Next() { if (buffer.Count != 0) return buffer.Dequeue(); string[] inputs = Console.ReadLine().Split(separator, StringSplitOptions.RemoveEmptyEntries); foreach (var input in inputs) { buffer.Enqueue(parse(input)); } return buffer.Dequeue(); } public T[] Next(int n) { var result = new T[n]; for (int i = 0; i < n; i++) { result[i] = Next(); } return result; } public List NextList(int n) { var result = new List(); for (int i = 0; i < n; i++) { result.Add(Next()); } return result; } } class Program { static void Main() { const int MOD = 998244353; Scanner sc = new Scanner(s => s); string st = sc.Next(); int n = st.Length; int q = st.Count(c => c == '?'); long ans = 0; for (int i = 0; i < (1 << q); i++) { char[] t = st.ToCharArray(); for (int j = 0; j < q; j++) { if (((i >> j) & 1) == 0) { t[GetIndexOfQuestionMark(st, j)] = '0'; } else { t[GetIndexOfQuestionMark(st, j)] = '1'; } } string sPrime = new string(t); ans = (ans + Count010Substrings(sPrime)) % MOD; } Console.WriteLine(ans); } static int GetIndexOfQuestionMark(string s, int qIndex) { int count = -1; for (int i = 0; i < s.Length; i++) { if (s[i] == '?') { count++; if (count == qIndex) { return i; } } } return -1; } static long Count010Substrings(string s) { int n = s.Length; int[] preSum = new int[n + 1]; preSum[0] = 0; for (int i = 1; i <= n; i++) { preSum[i] = preSum[i - 1] + (s[i - 1] == '0' ? 1 : 0); } long ans = 0; int num10 = 0; for (int i = n - 1; i >= 0; i--) { if (s[i] == '1') { num10 += preSum[n] - preSum[i + 1]; } else if (s[i] == '0') { ans += num10; } } return ans; } }