#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 305;

// Mod int
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
//

// mint dp[MX][MX][MX];
mint co[MX][MX];

mint f(int n, int k) {
  if (!k) return 1;
  if (!n) return 0;
  return co[n-1+k][k];
}

bool d[MX][MX][MX];

int main() {
  co[0][0] = 1;
  rep(i,MX-1) {
    rep(j,i+1) {
      co[i+1][j] += co[i][j];
      co[i+1][j+1] += co[i][j];
    }
  }
  string s;
  cin>>s;
  int n = sz(s);
  vi c(2), e(2);
  // rep(i,n) c[s[i]-'0']++;

  // int na = c[0], nb = c[1];
  // dp[0][0][0] = 1;
  // rep(i,na+nb+1) {
  //   rep(j,na+1)rep(k,nb+1) {
  //     dp[i+1][j+1][k] += dp[i][j][k];
  //     dp[i+1][j][k+1] += dp[i][j][k];
  //   }
  // }
  // rep(i,na+nb+1) {
  //   rep(j,na+1)rep(k,nb+1) dp[i][j][k+1] += dp[i][j][k];
  //   rep(j,na+1)rep(k,nb+1) dp[i][j+1][k] += dp[i][j][k];
  // }

  d[0][0][0] = 1;
  rep(i,n+1)rep(j,n+1)rep(k,n+1) {
    if (!d[i][j][k]) continue;
    if (j && j+k >= 2) d[i][j-1][k] = 1;
    if (k && j+k >= 2) d[i][j][k-1] = 1;
    if (i < n) {
      int x = s[i]-'0';
      int ni = i+1;
      int nj = j+!x, nk = k+x;
      if (nj) d[ni][nj-1][nk] = 1;
      if (nk) d[ni][nj][nk-1] = 1;
      if (i+1 < n) {
        int y = s[i+1]-'0';
        ni++;
        nj += !y; nk += y;
        if (x+y != 2) d[ni][nj-1][nk] = 1;
        if (x+y != 0) d[ni][nj][nk-1] = 1;
      }
    }
  }
  d[n][0][0] = 0;

  mint ans = 0;
  drep(i,n+1) {
    rep(j,n+1)rep(k,n+1) {
      int ex = 0;
      if (i < n) {
        int x = s[i]-'0';
        int nj = j+!x, nk = k+x;
        if (d[i+1][nj][nk]) ex = 1;
      }
      d[i][j][k] |= ex;
      if (ex) continue;
      if (!d[i][j][k]) continue;
      rep(sj,j+1)rep(sk,k+1) {
        mint now = f(c[1],sj);
        now *= f(c[0],sk);
        // cerr<<now<<endl;
        now *= co[j+k-sj-sk][j-sj];
        // cerr<<sj<<" "<<sk<<" "<<now<<endl;
        ans += now; 
      }
      // cerr<<(n-i)<<" "<<j<<" "<<k<<" "<<ans<<endl;
    }
    c[s[i-1]-'0']++;
  }

  // mint ans = 1;
  // int m = 0;
  // vi l(2);
  // for (int i = 0; i+2 <= n; i += 2) {
  //   c[s[i]-'0']--; c[s[i+1]-'0']--;
  //   int x = s[i]-'0';
  //   x += s[i+1]-'0';
  //   e[s[i]-'0']++; e[s[i+1]-'0']++;
  //   l[s[i]-'0']++; l[s[i+1]-'0']++;
  //   l[0]--; l[1]--;
  //   maxs(l[0],0);
  //   maxs(l[1],0);
  //   ++m;
  //   mins(e[0], m-l[1]);
  //   mins(e[1], m-l[0]);
  //   cerr<<e<<endl;
  //   rep(j,m+1)rep(k,m+1-j) {
  //     if (j > e[0]) break;
  //     if (k > e[1]) break;
  //     mint now = dp[m-j-k][e[0]-j][e[1]-k];
  //     now *= f(c[1],j);
  //     now *= f(c[0],k);
  //     cerr<<i<<" "<<j<<" "<<k<<" "<<now<<endl;
  //     ans += now;
  //   }
  // }
  // e[0] += c[0];e[1] += c[1];
  // l[0] += c[0];l[1] += c[1];
  // l[0]--; l[1]--;
  // maxs(l[0],0);
  // maxs(l[1],0);
  // ++m;
  // mins(e[0], m-l[1]);
  // mins(e[1], m-l[0]);

  // int r = n-m;
  // // cerr<<ans<<" "<<r<<endl;
  // while (r) {
  //   ans += dp[r][e[0]][e[1]];
  //   --r;
  // }
  cout<<ans<<endl;
  return 0;
}





















### Prompt

Please provide a cpp coded solution to the problem described below:

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 <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 305;

// Mod int
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
//

// mint dp[MX][MX][MX];
mint co[MX][MX];

mint f(int n, int k) {
  if (!k) return 1;
  if (!n) return 0;
  return co[n-1+k][k];
}

bool d[MX][MX][MX];

int main() {
  co[0][0] = 1;
  rep(i,MX-1) {
    rep(j,i+1) {
      co[i+1][j] += co[i][j];
      co[i+1][j+1] += co[i][j];
    }
  }
  string s;
  cin>>s;
  int n = sz(s);
  vi c(2), e(2);
  // rep(i,n) c[s[i]-'0']++;

  // int na = c[0], nb = c[1];
  // dp[0][0][0] = 1;
  // rep(i,na+nb+1) {
  //   rep(j,na+1)rep(k,nb+1) {
  //     dp[i+1][j+1][k] += dp[i][j][k];
  //     dp[i+1][j][k+1] += dp[i][j][k];
  //   }
  // }
  // rep(i,na+nb+1) {
  //   rep(j,na+1)rep(k,nb+1) dp[i][j][k+1] += dp[i][j][k];
  //   rep(j,na+1)rep(k,nb+1) dp[i][j+1][k] += dp[i][j][k];
  // }

  d[0][0][0] = 1;
  rep(i,n+1)rep(j,n+1)rep(k,n+1) {
    if (!d[i][j][k]) continue;
    if (j && j+k >= 2) d[i][j-1][k] = 1;
    if (k && j+k >= 2) d[i][j][k-1] = 1;
    if (i < n) {
      int x = s[i]-'0';
      int ni = i+1;
      int nj = j+!x, nk = k+x;
      if (nj) d[ni][nj-1][nk] = 1;
      if (nk) d[ni][nj][nk-1] = 1;
      if (i+1 < n) {
        int y = s[i+1]-'0';
        ni++;
        nj += !y; nk += y;
        if (x+y != 2) d[ni][nj-1][nk] = 1;
        if (x+y != 0) d[ni][nj][nk-1] = 1;
      }
    }
  }
  d[n][0][0] = 0;

  mint ans = 0;
  drep(i,n+1) {
    rep(j,n+1)rep(k,n+1) {
      int ex = 0;
      if (i < n) {
        int x = s[i]-'0';
        int nj = j+!x, nk = k+x;
        if (d[i+1][nj][nk]) ex = 1;
      }
      d[i][j][k] |= ex;
      if (ex) continue;
      if (!d[i][j][k]) continue;
      rep(sj,j+1)rep(sk,k+1) {
        mint now = f(c[1],sj);
        now *= f(c[0],sk);
        // cerr<<now<<endl;
        now *= co[j+k-sj-sk][j-sj];
        // cerr<<sj<<" "<<sk<<" "<<now<<endl;
        ans += now; 
      }
      // cerr<<(n-i)<<" "<<j<<" "<<k<<" "<<ans<<endl;
    }
    c[s[i-1]-'0']++;
  }

  // mint ans = 1;
  // int m = 0;
  // vi l(2);
  // for (int i = 0; i+2 <= n; i += 2) {
  //   c[s[i]-'0']--; c[s[i+1]-'0']--;
  //   int x = s[i]-'0';
  //   x += s[i+1]-'0';
  //   e[s[i]-'0']++; e[s[i+1]-'0']++;
  //   l[s[i]-'0']++; l[s[i+1]-'0']++;
  //   l[0]--; l[1]--;
  //   maxs(l[0],0);
  //   maxs(l[1],0);
  //   ++m;
  //   mins(e[0], m-l[1]);
  //   mins(e[1], m-l[0]);
  //   cerr<<e<<endl;
  //   rep(j,m+1)rep(k,m+1-j) {
  //     if (j > e[0]) break;
  //     if (k > e[1]) break;
  //     mint now = dp[m-j-k][e[0]-j][e[1]-k];
  //     now *= f(c[1],j);
  //     now *= f(c[0],k);
  //     cerr<<i<<" "<<j<<" "<<k<<" "<<now<<endl;
  //     ans += now;
  //   }
  // }
  // e[0] += c[0];e[1] += c[1];
  // l[0] += c[0];l[1] += c[1];
  // l[0]--; l[1]--;
  // maxs(l[0],0);
  // maxs(l[1],0);
  // ++m;
  // mins(e[0], m-l[1]);
  // mins(e[1], m-l[0]);

  // int r = n-m;
  // // cerr<<ans<<" "<<r<<endl;
  // while (r) {
  //   ans += dp[r][e[0]][e[1]];
  //   --r;
  // }
  cout<<ans<<endl;
  return 0;
}





















```