#include <iostream>
#include <string>
#include <bitset>

using namespace std;

typedef long long ll;

const int MOD = 998244353; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 305;
const int MAX_X = 155;

Modint dp [MAX_N][MAX_N][MAX_N];
// Modint udp [MAX_N][MAX_N][MAX_N];
// dp[len][pos][c0] - the # of strings length len with

int arr [MAX_N];
// Modint choose [MAX_N][MAX_N];
bitset<MAX_X> pdp [MAX_N][MAX_N][MAX_N];
// <position, # taken, # 0>

int main () {
  /*
  choose[0][0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    choose[i][0] = Modint(1);
    for (int j = 1; j < MAX_N; j++) {
      choose[i][j] = choose[i - 1][j - 1] + choose[i - 1][j];
    }
  }
  */  

  string s;
  cin >> s;

  int n = s.size();
  for (int i = 0; i < n; i++) {
    arr[i] = s[i] - '0';
  }

  dp[0][n][0] = Modint(1);
  for (int i = 0; i < n; i++) {
    for (int j = n; j >= 1; j--) {
      for (int k = 0; k < n; k++) {
        if (arr[j - 1] == 0) {
          dp[i + 1][j - 1][k] += dp[i][j][k];
          dp[i + 1][j][k] += dp[i][j][k];
        } else {
          dp[i + 1][j - 1][k] += dp[i][j][k];
          dp[i + 1][j][k + 1] += dp[i][j][k];
        }
      }
    }
  }

  /*
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        udp[i][j][k] = dp[i][j][k];
        
        if (j - 1 >= 0) {
          if (arr[j - 1] == 0) {
            if (k - 1 >= 0) { 
              udp[i][j][k] += udp[i][j - 1][k - 1];
            }
          } else {
            udp[i][j][k] += udp[i][j - 1][k];
          }
        }
      }
    }
  }
  */

  pdp[0][0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (pdp[i][j][k].any()) {
          pdp[i + 1][j][k] |= pdp[i][j][k];
          pdp[i + 2][j][k] |= pdp[i][j][k] << 1;
          pdp[i + 2][j + 1][k + (arr[i] == 0)] |= pdp[i][j][k];
          pdp[i + 2][j + 1][k + (arr[i + 1] == 0)] |= pdp[i][j][k];
          pdp[i + 1][j + 1][k + (arr[i] == 0)] |= pdp[i][j][k] >> 1;
        }
      }
    }
  }
  
  Modint ans (0);
  /*
  for (int i = 0; i <= n; i += 2) { // prefix size
    int c0p = 0;
    for (int j = 0; j < i; j++) {
      if (arr[j] == 0) {
        c0p++;
      }
    }
    int c1p = i - c0p;

    for (int c0 = 0; c0 <= i / 2; c0++) {
      int c1 = i / 2 - c0;
      if (c0 <= c0p && c1 <= c1p && pdp[i][i / 2][c0]) {
        cerr << " " << i << " " << c0 << " " << c1 << " | " << udp[n - i + i / 2][i][c0] << endl;
        ans += udp[n - i + i / 2][i][c0];
      }
    }
  }
  */
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (pdp[i][j][k].any()) {
          // cerr << " " << i << " " << k << " " << j - k << " | " << dp[n - i + j][i][k] << endl;
          ans += dp[n - i + j][i][k];
        }
      }
    }
  }

  /*
  int c0a = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      c0a++;
    }
  }
  int c1a = n - c0a;

  for (int i = 1; 2 * i < n; i++) {
    for (int c0 = 0; c0 <= i; c0++) {
      int c1 = i - c0;
      if (c0 <= c0a && c1 <= c1a) {
        cerr << "  " << c0 << " " << c1 << " " << choose[i][c0] << endl;
        ans += choose[i][c0];
      }
    }
  }
  */

  cout << ans - Modint(1) << endl;
}

### Prompt

Generate a cpp solution to the following problem:

Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S zero or more times:

* Remove the two characters at the beginning of S, erase one of them, and reinsert the other somewhere in S. This operation can be applied only when S has two or more characters.

Constraints

* 1 \leq |S| \leq 300
* S consists of `0` and `1`.

Input

Input is given from Standard Input in the following format:


S


Output

Print the number of strings, modulo 998244353, that can result from applying the operation on S zero or more times.

Examples

Input

0001


Output

8


Input

110001


Output

24


Input

11101111011111000000000110000001111100011111000000001111111110000000111111111


Output

697354558

### Response

```cpp
#include <iostream>
#include <string>
#include <bitset>

using namespace std;

typedef long long ll;

const int MOD = 998244353; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 305;
const int MAX_X = 155;

Modint dp [MAX_N][MAX_N][MAX_N];
// Modint udp [MAX_N][MAX_N][MAX_N];
// dp[len][pos][c0] - the # of strings length len with

int arr [MAX_N];
// Modint choose [MAX_N][MAX_N];
bitset<MAX_X> pdp [MAX_N][MAX_N][MAX_N];
// <position, # taken, # 0>

int main () {
  /*
  choose[0][0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    choose[i][0] = Modint(1);
    for (int j = 1; j < MAX_N; j++) {
      choose[i][j] = choose[i - 1][j - 1] + choose[i - 1][j];
    }
  }
  */  

  string s;
  cin >> s;

  int n = s.size();
  for (int i = 0; i < n; i++) {
    arr[i] = s[i] - '0';
  }

  dp[0][n][0] = Modint(1);
  for (int i = 0; i < n; i++) {
    for (int j = n; j >= 1; j--) {
      for (int k = 0; k < n; k++) {
        if (arr[j - 1] == 0) {
          dp[i + 1][j - 1][k] += dp[i][j][k];
          dp[i + 1][j][k] += dp[i][j][k];
        } else {
          dp[i + 1][j - 1][k] += dp[i][j][k];
          dp[i + 1][j][k + 1] += dp[i][j][k];
        }
      }
    }
  }

  /*
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        udp[i][j][k] = dp[i][j][k];
        
        if (j - 1 >= 0) {
          if (arr[j - 1] == 0) {
            if (k - 1 >= 0) { 
              udp[i][j][k] += udp[i][j - 1][k - 1];
            }
          } else {
            udp[i][j][k] += udp[i][j - 1][k];
          }
        }
      }
    }
  }
  */

  pdp[0][0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (pdp[i][j][k].any()) {
          pdp[i + 1][j][k] |= pdp[i][j][k];
          pdp[i + 2][j][k] |= pdp[i][j][k] << 1;
          pdp[i + 2][j + 1][k + (arr[i] == 0)] |= pdp[i][j][k];
          pdp[i + 2][j + 1][k + (arr[i + 1] == 0)] |= pdp[i][j][k];
          pdp[i + 1][j + 1][k + (arr[i] == 0)] |= pdp[i][j][k] >> 1;
        }
      }
    }
  }
  
  Modint ans (0);
  /*
  for (int i = 0; i <= n; i += 2) { // prefix size
    int c0p = 0;
    for (int j = 0; j < i; j++) {
      if (arr[j] == 0) {
        c0p++;
      }
    }
    int c1p = i - c0p;

    for (int c0 = 0; c0 <= i / 2; c0++) {
      int c1 = i / 2 - c0;
      if (c0 <= c0p && c1 <= c1p && pdp[i][i / 2][c0]) {
        cerr << " " << i << " " << c0 << " " << c1 << " | " << udp[n - i + i / 2][i][c0] << endl;
        ans += udp[n - i + i / 2][i][c0];
      }
    }
  }
  */
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (pdp[i][j][k].any()) {
          // cerr << " " << i << " " << k << " " << j - k << " | " << dp[n - i + j][i][k] << endl;
          ans += dp[n - i + j][i][k];
        }
      }
    }
  }

  /*
  int c0a = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      c0a++;
    }
  }
  int c1a = n - c0a;

  for (int i = 1; 2 * i < n; i++) {
    for (int c0 = 0; c0 <= i; c0++) {
      int c1 = i - c0;
      if (c0 <= c0a && c1 <= c1a) {
        cerr << "  " << c0 << " " << c1 << " " << choose[i][c0] << endl;
        ans += choose[i][c0];
      }
    }
  }
  */

  cout << ans - Modint(1) << endl;
}

```