#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<998244353>;

template<class Mint,int32_t lg>
struct ModIntTable{
	int N;
	vector<Mint>facts,finvs,invs;
	ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){
		const uint32_t mod=Mint(-1).a+1;
		invs[1]=1;
		for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i);

		facts[0]=1;
		finvs[0]=1;
		for(int i=1;i<N;i++){
			facts[i]=facts[i-1]*i;
			finvs[i]=finvs[i-1]*invs[i];
		}
	}
	inline Mint fact(int n)const{return facts[n];}
	inline Mint finv(int n)const{return finvs[n];}
	inline Mint inv(int n)const{return invs[n];}
	inline Mint binom(int n,int k)const{
		if(n<0||k<0||k>n)return 0;
		return facts[n]*finvs[k]*finvs[n-k];
	}
	inline Mint perm(int n,int k)const{
		if(n<0||k<0||k>n)return 0;
		return facts[n]*finvs[n-k];
	}
	inline Mint catalan(int n){
		return facts[2*n]*finvs[n+1]*finvs[n];
	}
};
ModIntTable<mint,20>mt;

int N;
string S;


bool ex[333][333][333];
int sufcnt0[333];



signed main(){
	cin>>S;
	N=S.size();
	ex[0][0][0]=true;
	sufcnt0[N]=0;
	for(int i=N-1;i>=0;i--){
		sufcnt0[i]=sufcnt0[i+1];
		if(S[i]=='0')sufcnt0[i]++;
	}
	rep(i,N+1){
		for(int j=N;j>=0;j--){
			for(int k=N;k>=0;k--){
				if(!ex[i][j][k])continue;
				if(i+2<=N){
					rep(l,2)ex[i+2][j+1-(S[i+l]-'0')][k+(S[i+l]-'0')]=true;
				}
				if(j+k&&i+1<=N){
					ex[i+1][j][k]=true;
					if(j)ex[i+1][j-1+1-(S[i]-'0')][k+(S[i]-'0')]=true;
					if(k)ex[i+1][j+1-(S[i]-'0')][k-1+(S[i]-'0')]=true;
				}
				if(j+k>=2){
					if(j)ex[i][j-1][k]=true;
					ex[i][j][k-1]=true;
				}
			}
		}
	}

	map<pint,int>ma;
	rep(i,N+1)rep(j,N+1)rep(k,N+1)if(ex[i][j][k]){
		int cnt0=j+sufcnt0[i];
		int cnt1=k+N-i-sufcnt0[i];

		pint p(cnt0,cnt1);
		if(ma.find(p)==ma.end())ma[p]=i;
		else chmax(ma[p],i);
	}
	mint ans=0;
	for(auto &p:ma){
		int cnt0=p.fi.fi;
		int cnt1=p.fi.se;
		int i=p.se;

		int j=cnt0-sufcnt0[i];
		int k=cnt1-(N-i)+sufcnt0[i];

		for(int z=0;z<=j;z++){
			mint tmp=1;
			if(z)tmp*=mt.binom(z+(N-i-sufcnt0[i])-1,z);
			tmp*=mt.binom(k+sufcnt0[i]+(j-z),k);
			ans+=tmp;
		}
	}

	cout<<ans<<endl;
	return 0;
}

### Prompt

Create a solution in CPP for 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<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<998244353>;

template<class Mint,int32_t lg>
struct ModIntTable{
	int N;
	vector<Mint>facts,finvs,invs;
	ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){
		const uint32_t mod=Mint(-1).a+1;
		invs[1]=1;
		for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i);

		facts[0]=1;
		finvs[0]=1;
		for(int i=1;i<N;i++){
			facts[i]=facts[i-1]*i;
			finvs[i]=finvs[i-1]*invs[i];
		}
	}
	inline Mint fact(int n)const{return facts[n];}
	inline Mint finv(int n)const{return finvs[n];}
	inline Mint inv(int n)const{return invs[n];}
	inline Mint binom(int n,int k)const{
		if(n<0||k<0||k>n)return 0;
		return facts[n]*finvs[k]*finvs[n-k];
	}
	inline Mint perm(int n,int k)const{
		if(n<0||k<0||k>n)return 0;
		return facts[n]*finvs[n-k];
	}
	inline Mint catalan(int n){
		return facts[2*n]*finvs[n+1]*finvs[n];
	}
};
ModIntTable<mint,20>mt;

int N;
string S;


bool ex[333][333][333];
int sufcnt0[333];



signed main(){
	cin>>S;
	N=S.size();
	ex[0][0][0]=true;
	sufcnt0[N]=0;
	for(int i=N-1;i>=0;i--){
		sufcnt0[i]=sufcnt0[i+1];
		if(S[i]=='0')sufcnt0[i]++;
	}
	rep(i,N+1){
		for(int j=N;j>=0;j--){
			for(int k=N;k>=0;k--){
				if(!ex[i][j][k])continue;
				if(i+2<=N){
					rep(l,2)ex[i+2][j+1-(S[i+l]-'0')][k+(S[i+l]-'0')]=true;
				}
				if(j+k&&i+1<=N){
					ex[i+1][j][k]=true;
					if(j)ex[i+1][j-1+1-(S[i]-'0')][k+(S[i]-'0')]=true;
					if(k)ex[i+1][j+1-(S[i]-'0')][k-1+(S[i]-'0')]=true;
				}
				if(j+k>=2){
					if(j)ex[i][j-1][k]=true;
					ex[i][j][k-1]=true;
				}
			}
		}
	}

	map<pint,int>ma;
	rep(i,N+1)rep(j,N+1)rep(k,N+1)if(ex[i][j][k]){
		int cnt0=j+sufcnt0[i];
		int cnt1=k+N-i-sufcnt0[i];

		pint p(cnt0,cnt1);
		if(ma.find(p)==ma.end())ma[p]=i;
		else chmax(ma[p],i);
	}
	mint ans=0;
	for(auto &p:ma){
		int cnt0=p.fi.fi;
		int cnt1=p.fi.se;
		int i=p.se;

		int j=cnt0-sufcnt0[i];
		int k=cnt1-(N-i)+sufcnt0[i];

		for(int z=0;z<=j;z++){
			mint tmp=1;
			if(z)tmp*=mt.binom(z+(N-i-sufcnt0[i])-1,z);
			tmp*=mt.binom(k+sufcnt0[i]+(j-z),k);
			ans+=tmp;
		}
	}

	cout<<ans<<endl;
	return 0;
}

```