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

using ll=long long;
#define rng(i,l,r) for(int i=int(l);i<=int(r);i++)
#define rep(i,r) for(int i=0;i<int(r);i++)
#define rrng(i,l,r) for(int i=int(r);i>=int(l);i--)
#define rrep(i,r) for(int i=int(r)-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#define inf INT_MAX/2-100
#define infl LLONG_MAX/3
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u>void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u>void chmin(t&a,u b){if(b<a)a=b;}

template<class t>using vc=vector<t>;
template<class t>using vvc=vector<vector<t>>;

using pi=pair<int,int>;
using pl=pair<ll,ll>;
using vi=vc<int>;
using vl=vc<ll>;


ll readl(void){
	ll x;
	cin>>x;
	return x;
}
int readi(void){
	int x;
	cin>>x;
	return x;
}

string readstr(){
	string s;
	cin>>s;
	return s;
}
vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=readi(),v[i]+=off;
	return v;
}

vl readvl(int n,int off=0){
	vl v(n);
	rep(i,n)v[i]=readl(),v[i]+=off;
	return v;
}

template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)cout<<"\n";
	if(suc==2)cout<<" ";
}

template<class t>
void print(const vc<t>&v,int suc=1){
	rep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);
}

template<class t>
bool inc(t a,t b,t c){
	return !(c<b||b<a);
}

template<class t>
void compress(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}

template<class t>
struct Compress{
	vc<t>v;
	Compress()=default;
	Compress(const vc<t>&x){
		add(x);
	}
	Compress(const initializer_list<vc<t> >&x){
		for(auto &p:x)add(p);
	}
	void add(const t&x){
		v.eb(x);
	}
	void add(const vc<t>&x){
		copy(all(x),back_inserter(v));
	}
	void build(){
		compress(v);
	}
	int get(const t&x)const{
		return lwb(v,x);
	}
	vc<t>get(const vc<t>&x)const{
		vc<t>res(x);
		for(auto &p:res)p=get(p);
		return res;
	}
	const t &operator[](int x)const{
		return v[x];
	}
};
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
}
void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
}
void orYes(bool x,bool ex=true){
	if(x)Yes(ex);
	else No(ex);
}
void orYES(bool x,bool ex=true){
	if(x)YES(ex);
	else NO(ex);
}
void Possible(bool ex=true){
	cout<<"Possible\n";
	if(ex)exit(0);
}
void POSSIBLE(bool ex=true){
	cout<<"POSSIBLE\n";
	if(ex)exit(0);
}
void Impossible(bool ex=true){
	cout<<"Impossible\n";
	if(ex)exit(0);
}
void IMPOSSIBLE(bool ex=true){
	cout<<"IMPOSSIBLE\n";
	if(ex)exit(0);
}
void orPossible(bool x,bool ex=true){
	if(x)Possible(ex);
	else Impossible(ex);
}
void orPOSSIBLE(bool x,bool ex=true){
	if(x)POSSIBLE(ex);
	else IMPOSSIBLE(ex);
}

int gcd(int x,int y){
	if(x<y)swap(x,y);
	if(x%y==0)return y;
	return gcd(y,x%y);
}

using uint=unsigned;
using ull=unsigned long long; 

template<uint const& MOD>
struct Modular{
	static constexpr uint const &mod=MOD;
	uint v;
	Modular(long long x=0){c(x%mod+mod);}
	Modular& c(uint x){
		v=x<mod?x:x-mod;
		return *this;
	}
	Modular pow(int k)const{
		Modular res(1),tmp(v);
		while(k){
			if(k&1)res*=tmp;
			tmp*=tmp;
			k>>=1;
		}
		return res;
	}

	Modular inv()const{return pow(mod-2);}
	Modular operator-()const{return Modular(mod-v);}

	Modular& operator+=(const Modular &x){return c(v+x.v);}
	Modular& operator-=(const Modular &x){return c(v+mod-x.v);}
	Modular& operator*=(const Modular &x){v=ull(v)*x.v%mod;return *this;}
	Modular& operator/=(const Modular &x){return *this*=x.inv();}

	Modular operator+(const Modular &x)const{return Modular(*this)+=x;}
	Modular operator-(const Modular &x)const{return Modular(*this)-=x;}
	Modular operator*(const Modular &x)const{return Modular(*this)*=x;}
	Modular operator/(const Modular &x)const{return Modular(*this)/=x;}

	friend Modular operator+(long long x,const Modular &y){return Modular(x)+y;}
	friend Modular operator-(long long x,const Modular &y){return Modular(x)-y;}
	friend Modular operator*(long long x,const Modular &y){return Modular(x)*y;}
	friend Modular operator/(long long x,const Modular &y){return Modular(x)/y;}

	friend ostream& operator<<(ostream&os,const Modular&x){
		return os<<x.v;
	}
	friend istream& operator>>(istream&is,Modular&x){
		long long p;
		is>>p;
		x=Modular(p);
		return is;
	}
	bool operator==(const Modular &x)const{return v==x.v;}
	bool operator!=(const Modular &x)const{return v!=x.v;}
	bool operator<(const Modular &x)const{return v<x.v;}
	explicit operator bool()const{return v;}
};

uint MODULAR=998244353;
//uint MODULAR=1000000007;
using Mint=Modular<MODULAR>; 

vector<Mint>fact,finv,invs;
void Initfact(int n=(1<<21)+10){
	fact.resize(n+1),finv.resize(n+1),invs.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i;
	}
	finv[n]=fact[n].inv();
	for(int i=n-1;i>=0;i--){
		finv[i]=finv[i+1]*(i+1);
	}
	invs[0]=1;
	for(int i=0;i<=n;i++){
		invs[i]=finv[i]*fact[i-1];
	}
}

Mint comb(int n,int k){
	return fact[n]*finv[n-k]*finv[k];
}


string s;
bool can[605][605][605];
int n,sumz[605],sumo[605],mx[605][605];
Mint dp[605][605][605],ans;
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>s;
	n=si(s);
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	can[0][0][0]=true;
	for(int i=0;i<=n;i++){
		if(s[i]=='0')sumz[i]++;
		else sumo[i]++;
		if(i>0){
			sumz[i]+=sumz[i-1];
			sumo[i]+=sumo[i-1];
		}
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(!can[i][j][k])continue;
				if(i+1<si(s)){
					if(s[i]=='0')can[i+2][j+1][k+1]=true;
					else can[i+2][j+1][k]=true;
					if(s[i+1]=='0')can[i+2][j+1][k+1]=true;
					else can[i+2][j+1][k]=true;
				}
				if(i>0){
					if(sumz[i-1]>k){
						can[i+1][j+1][k+1]=true;
						if(s[i]=='1'){
							can[i+1][j+1][k]=true;
						}
					}
					if(sumo[i-1]>j-k){
						can[i+1][j+1][k]=true;
						if(s[i]=='0'){
							can[i+1][j+1][k+1]=true;
						}
					}
				}
				int x=sumz[i-1]-k,y=sumo[i-1]-(j-k);
				//cout<<i<<' '<<j<<' '<<k<<' '<<x<<' '<<y<<endl;
				if(x>1){
					can[i][j+1][k+1]=true;
				}
				if(x>0&&y>0){
					can[i][j+1][k+1]=true;
					can[i][j+1][k]=true;
				}
				if(y>1){
					can[i][j+1][k]=true;
				}
			}
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			mx[i][j]=-1;
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(can[i][j][k]){
					//cout<<i<<' '<<j<<' '<<k<<endl;
					chmax(mx[j][k],i);
				}
			}
		}
	}
	dp[n][0][0]=1;
	for(int i=n;i>0;i--){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(s[i-1]=='0'){
					dp[i-1][j+1][k]+=dp[i][j][k];
					dp[i][j][k+1]+=dp[i][j][k];
				}else{
					dp[i-1][j][k+1]+=dp[i][j][k];
					dp[i][j+1][k]+=dp[i][j][k];
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				dp[i][j][k]+=dp[i-1][j][k];
			}
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(mx[i][j]==-1)continue;
			int x=sumz[n-1]-j,y=sumo[n-1]-(i-j);
			//cout<<mx[i][j]<<' '<<x<<' '<<y<<' '<<dp[mx[i][j]][x][y]<<endl;
			ans+=dp[mx[i][j]][x][y];
		}
	}
	print(ans);
}

### 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 <bits/stdc++.h>
using namespace std;

using ll=long long;
#define rng(i,l,r) for(int i=int(l);i<=int(r);i++)
#define rep(i,r) for(int i=0;i<int(r);i++)
#define rrng(i,l,r) for(int i=int(r);i>=int(l);i--)
#define rrep(i,r) for(int i=int(r)-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#define inf INT_MAX/2-100
#define infl LLONG_MAX/3
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u>void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u>void chmin(t&a,u b){if(b<a)a=b;}

template<class t>using vc=vector<t>;
template<class t>using vvc=vector<vector<t>>;

using pi=pair<int,int>;
using pl=pair<ll,ll>;
using vi=vc<int>;
using vl=vc<ll>;


ll readl(void){
	ll x;
	cin>>x;
	return x;
}
int readi(void){
	int x;
	cin>>x;
	return x;
}

string readstr(){
	string s;
	cin>>s;
	return s;
}
vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=readi(),v[i]+=off;
	return v;
}

vl readvl(int n,int off=0){
	vl v(n);
	rep(i,n)v[i]=readl(),v[i]+=off;
	return v;
}

template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)cout<<"\n";
	if(suc==2)cout<<" ";
}

template<class t>
void print(const vc<t>&v,int suc=1){
	rep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);
}

template<class t>
bool inc(t a,t b,t c){
	return !(c<b||b<a);
}

template<class t>
void compress(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}

template<class t>
struct Compress{
	vc<t>v;
	Compress()=default;
	Compress(const vc<t>&x){
		add(x);
	}
	Compress(const initializer_list<vc<t> >&x){
		for(auto &p:x)add(p);
	}
	void add(const t&x){
		v.eb(x);
	}
	void add(const vc<t>&x){
		copy(all(x),back_inserter(v));
	}
	void build(){
		compress(v);
	}
	int get(const t&x)const{
		return lwb(v,x);
	}
	vc<t>get(const vc<t>&x)const{
		vc<t>res(x);
		for(auto &p:res)p=get(p);
		return res;
	}
	const t &operator[](int x)const{
		return v[x];
	}
};
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
}
void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
}
void orYes(bool x,bool ex=true){
	if(x)Yes(ex);
	else No(ex);
}
void orYES(bool x,bool ex=true){
	if(x)YES(ex);
	else NO(ex);
}
void Possible(bool ex=true){
	cout<<"Possible\n";
	if(ex)exit(0);
}
void POSSIBLE(bool ex=true){
	cout<<"POSSIBLE\n";
	if(ex)exit(0);
}
void Impossible(bool ex=true){
	cout<<"Impossible\n";
	if(ex)exit(0);
}
void IMPOSSIBLE(bool ex=true){
	cout<<"IMPOSSIBLE\n";
	if(ex)exit(0);
}
void orPossible(bool x,bool ex=true){
	if(x)Possible(ex);
	else Impossible(ex);
}
void orPOSSIBLE(bool x,bool ex=true){
	if(x)POSSIBLE(ex);
	else IMPOSSIBLE(ex);
}

int gcd(int x,int y){
	if(x<y)swap(x,y);
	if(x%y==0)return y;
	return gcd(y,x%y);
}

using uint=unsigned;
using ull=unsigned long long; 

template<uint const& MOD>
struct Modular{
	static constexpr uint const &mod=MOD;
	uint v;
	Modular(long long x=0){c(x%mod+mod);}
	Modular& c(uint x){
		v=x<mod?x:x-mod;
		return *this;
	}
	Modular pow(int k)const{
		Modular res(1),tmp(v);
		while(k){
			if(k&1)res*=tmp;
			tmp*=tmp;
			k>>=1;
		}
		return res;
	}

	Modular inv()const{return pow(mod-2);}
	Modular operator-()const{return Modular(mod-v);}

	Modular& operator+=(const Modular &x){return c(v+x.v);}
	Modular& operator-=(const Modular &x){return c(v+mod-x.v);}
	Modular& operator*=(const Modular &x){v=ull(v)*x.v%mod;return *this;}
	Modular& operator/=(const Modular &x){return *this*=x.inv();}

	Modular operator+(const Modular &x)const{return Modular(*this)+=x;}
	Modular operator-(const Modular &x)const{return Modular(*this)-=x;}
	Modular operator*(const Modular &x)const{return Modular(*this)*=x;}
	Modular operator/(const Modular &x)const{return Modular(*this)/=x;}

	friend Modular operator+(long long x,const Modular &y){return Modular(x)+y;}
	friend Modular operator-(long long x,const Modular &y){return Modular(x)-y;}
	friend Modular operator*(long long x,const Modular &y){return Modular(x)*y;}
	friend Modular operator/(long long x,const Modular &y){return Modular(x)/y;}

	friend ostream& operator<<(ostream&os,const Modular&x){
		return os<<x.v;
	}
	friend istream& operator>>(istream&is,Modular&x){
		long long p;
		is>>p;
		x=Modular(p);
		return is;
	}
	bool operator==(const Modular &x)const{return v==x.v;}
	bool operator!=(const Modular &x)const{return v!=x.v;}
	bool operator<(const Modular &x)const{return v<x.v;}
	explicit operator bool()const{return v;}
};

uint MODULAR=998244353;
//uint MODULAR=1000000007;
using Mint=Modular<MODULAR>; 

vector<Mint>fact,finv,invs;
void Initfact(int n=(1<<21)+10){
	fact.resize(n+1),finv.resize(n+1),invs.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i;
	}
	finv[n]=fact[n].inv();
	for(int i=n-1;i>=0;i--){
		finv[i]=finv[i+1]*(i+1);
	}
	invs[0]=1;
	for(int i=0;i<=n;i++){
		invs[i]=finv[i]*fact[i-1];
	}
}

Mint comb(int n,int k){
	return fact[n]*finv[n-k]*finv[k];
}


string s;
bool can[605][605][605];
int n,sumz[605],sumo[605],mx[605][605];
Mint dp[605][605][605],ans;
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>s;
	n=si(s);
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	can[0][0][0]=true;
	for(int i=0;i<=n;i++){
		if(s[i]=='0')sumz[i]++;
		else sumo[i]++;
		if(i>0){
			sumz[i]+=sumz[i-1];
			sumo[i]+=sumo[i-1];
		}
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(!can[i][j][k])continue;
				if(i+1<si(s)){
					if(s[i]=='0')can[i+2][j+1][k+1]=true;
					else can[i+2][j+1][k]=true;
					if(s[i+1]=='0')can[i+2][j+1][k+1]=true;
					else can[i+2][j+1][k]=true;
				}
				if(i>0){
					if(sumz[i-1]>k){
						can[i+1][j+1][k+1]=true;
						if(s[i]=='1'){
							can[i+1][j+1][k]=true;
						}
					}
					if(sumo[i-1]>j-k){
						can[i+1][j+1][k]=true;
						if(s[i]=='0'){
							can[i+1][j+1][k+1]=true;
						}
					}
				}
				int x=sumz[i-1]-k,y=sumo[i-1]-(j-k);
				//cout<<i<<' '<<j<<' '<<k<<' '<<x<<' '<<y<<endl;
				if(x>1){
					can[i][j+1][k+1]=true;
				}
				if(x>0&&y>0){
					can[i][j+1][k+1]=true;
					can[i][j+1][k]=true;
				}
				if(y>1){
					can[i][j+1][k]=true;
				}
			}
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			mx[i][j]=-1;
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(can[i][j][k]){
					//cout<<i<<' '<<j<<' '<<k<<endl;
					chmax(mx[j][k],i);
				}
			}
		}
	}
	dp[n][0][0]=1;
	for(int i=n;i>0;i--){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(s[i-1]=='0'){
					dp[i-1][j+1][k]+=dp[i][j][k];
					dp[i][j][k+1]+=dp[i][j][k];
				}else{
					dp[i-1][j][k+1]+=dp[i][j][k];
					dp[i][j+1][k]+=dp[i][j][k];
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				dp[i][j][k]+=dp[i-1][j][k];
			}
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(mx[i][j]==-1)continue;
			int x=sumz[n-1]-j,y=sumo[n-1]-(i-j);
			//cout<<mx[i][j]<<' '<<x<<' '<<y<<' '<<dp[mx[i][j]][x][y]<<endl;
			ans+=dp[mx[i][j]][x][y];
		}
	}
	print(ans);
}

```