#include <bits/stdc++.h>
using namespace std;
char s[1005];
int n, k;
const int mod = 998244353;
int c[1005 << 1];
int idx(int id, int p) { return n * (id - 1) + p; }
bool give(int id, int cc) {
  if (c[id] >= 0) {
    if (c[id] != cc) return 0;
    return 1;
  }
  c[id] = cc;
  int r = 1 + (id > n);
  int t = id > n ? id - n : id;
  if (r == 1) {
    if (!give(idx(1, n + 1 - t), cc)) return 0;
    if (t <= k) {
      if (s[n + 1 - t] != '?') {
        if (!give(idx(2, t), cc ^ (s[n + 1 - t] - '0'))) return 0;
      }
    }
  } else {
    if (!give(idx(2, k + 1 - t), cc)) return 0;
    if (t <= k) {
      if (s[n + 1 - t] != '?') {
        if (!give(idx(1, t), cc ^ (s[n + 1 - t] - '0'))) return 0;
      }
    }
  }
  return 1;
}
int solve(int K) {
  k = K;
  int nn = n >> 1, kk = k >> 1;
  int tot = idx(2, k);
  for (int i = 1; i <= tot; i++) c[i] = -1;
  for (int i = k + 1; i <= n; i++)
    if (s[n + 1 - i] != '?') {
      if (!give(idx(1, i), s[n + 1 - i] - '0')) return 0;
    }
  if (!give(idx(2, k), 1)) return 0;
  int ans = 1;
  for (int i = 1; i <= tot; i++)
    if (c[i] < 0) {
      if (!give(i, 1)) return 0;
      ans <<= 1;
      if (ans >= mod) ans -= mod;
    }
  return ans;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  if (s[n] == '1') {
    puts("0");
    return 0;
  }
  s[n] = '0';
  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans += solve(i);
    if (ans >= mod) ans -= mod;
  }
  printf("%d\n", ans);
  return 0;
}
