#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

//#define MOD 1000000007
#define MOD 998244353
struct mint {
	int i;
	mint() : i(0) {}
	mint(int x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	template<class T> mint(T x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	mint operator+(const mint x) const {return i + x.i;}
	mint operator-(const mint x) const {return i - x.i;}
	mint operator*(const mint x) const {return (long long)i * x.i;}
	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}
	mint inv() {return pow(MOD - 2);}
	template<class T> mint pow(T p) const {
		long long r = 1;
		long long t = i;
		for(; p > 0; p >>= 1) {
			if (p & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	template<class T1, class T2> static mint pow(T1 a, T2 b) {
		long long r = 1;
		long long t = (long long)(a % MOD);
		for(; b > 0; b >>= 1) {
			if (b & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	mint& operator+=(const mint x) {
		i = (i + x.i) % MOD;
		return *this;
	}
	mint& operator-=(const mint x) {
		i = i - x.i;
		if (i < 0) i += MOD;
		return *this;
	}
	mint& operator*=(const mint x) {
		i = (int)((long long)i * x.i % MOD);
		return *this;
	}
	mint& operator/=(const mint x) {
		i = (long long)i * x.pow(MOD - 2).i % MOD;
		return *this;
	}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k == 0) return 1;
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(310);

int main() {
	string s;
	cin >> s;
	int len = s.size();
	vector<int> zacc(len+1), oacc(len+1);
	for(int i = len-1; i >= 0; i--) {
		zacc[i] = zacc[i+1] + (s[i] == '0');
		oacc[i] = oacc[i+1] + (s[i] == '1');
	}
	// dp[i] .. max next index with i 0s trashed
	vector<int> dp(301, -1);
	dp[0] = 0;
	mint ans(0);
	rep(rmcnt, len) {
		vector<int> ndp(301, -1);
		rep(i, 301) {
			if (dp[i] == -1) continue;
			int nxt = dp[i];
			int zcnt_unseen = zacc[nxt], ocnt_unseen = oacc[nxt];
			int zcnt_free = zacc[0] - zacc[nxt] - i,
			    ocnt_free = oacc[0] - oacc[nxt] - (rmcnt - i);
			rep(zcnt_after, zcnt_free + 1) {
				int zcnt_free_left = zcnt_free - zcnt_after;
				ans += comb(ocnt_unseen - 1 + zcnt_free_left, zcnt_free_left)
				     * comb(zcnt_unseen + zcnt_after + ocnt_free, ocnt_free);
			}
			if (zcnt_free + ocnt_free >= 2) {
				if (zcnt_free >= 1) chmax(ndp[i+1], nxt);
				if (ocnt_free >= 1) chmax(ndp[i], nxt);
			}
			if (nxt < len && zcnt_free + ocnt_free >= 1) {
				if (s[nxt] == '0') {
					chmax(ndp[i+1], nxt+1);
					if (ocnt_free >= 1) chmax(ndp[i], nxt+1);
				} else {
					chmax(ndp[i], nxt+1);
					if (zcnt_free >= 1) chmax(ndp[i+1], nxt+1);
				}
			}
			if (nxt < len - 1) {
				if (s[nxt] == s[nxt+1]) {
					chmax(ndp[i+(s[nxt] == '0')], nxt+2);
				} else {
					chmax(ndp[i+1], nxt+2);
					chmax(ndp[i], nxt+2);
				}
			}
		}
		dp = move(ndp);
	}
	cout << ans << endl;
	
}

### 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>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

//#define MOD 1000000007
#define MOD 998244353
struct mint {
	int i;
	mint() : i(0) {}
	mint(int x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	template<class T> mint(T x) {
		i = int(x % MOD);
		if (i < 0) i += MOD;
	}
	mint operator+(const mint x) const {return i + x.i;}
	mint operator-(const mint x) const {return i - x.i;}
	mint operator*(const mint x) const {return (long long)i * x.i;}
	mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;}
	mint inv() {return pow(MOD - 2);}
	template<class T> mint pow(T p) const {
		long long r = 1;
		long long t = i;
		for(; p > 0; p >>= 1) {
			if (p & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	template<class T1, class T2> static mint pow(T1 a, T2 b) {
		long long r = 1;
		long long t = (long long)(a % MOD);
		for(; b > 0; b >>= 1) {
			if (b & 1) r = r * t % MOD;
			t = t * t % MOD;
		}
		return r;
	}
	mint& operator+=(const mint x) {
		i = (i + x.i) % MOD;
		return *this;
	}
	mint& operator-=(const mint x) {
		i = i - x.i;
		if (i < 0) i += MOD;
		return *this;
	}
	mint& operator*=(const mint x) {
		i = (int)((long long)i * x.i % MOD);
		return *this;
	}
	mint& operator/=(const mint x) {
		i = (long long)i * x.pow(MOD - 2).i % MOD;
		return *this;
	}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k == 0) return 1;
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(310);

int main() {
	string s;
	cin >> s;
	int len = s.size();
	vector<int> zacc(len+1), oacc(len+1);
	for(int i = len-1; i >= 0; i--) {
		zacc[i] = zacc[i+1] + (s[i] == '0');
		oacc[i] = oacc[i+1] + (s[i] == '1');
	}
	// dp[i] .. max next index with i 0s trashed
	vector<int> dp(301, -1);
	dp[0] = 0;
	mint ans(0);
	rep(rmcnt, len) {
		vector<int> ndp(301, -1);
		rep(i, 301) {
			if (dp[i] == -1) continue;
			int nxt = dp[i];
			int zcnt_unseen = zacc[nxt], ocnt_unseen = oacc[nxt];
			int zcnt_free = zacc[0] - zacc[nxt] - i,
			    ocnt_free = oacc[0] - oacc[nxt] - (rmcnt - i);
			rep(zcnt_after, zcnt_free + 1) {
				int zcnt_free_left = zcnt_free - zcnt_after;
				ans += comb(ocnt_unseen - 1 + zcnt_free_left, zcnt_free_left)
				     * comb(zcnt_unseen + zcnt_after + ocnt_free, ocnt_free);
			}
			if (zcnt_free + ocnt_free >= 2) {
				if (zcnt_free >= 1) chmax(ndp[i+1], nxt);
				if (ocnt_free >= 1) chmax(ndp[i], nxt);
			}
			if (nxt < len && zcnt_free + ocnt_free >= 1) {
				if (s[nxt] == '0') {
					chmax(ndp[i+1], nxt+1);
					if (ocnt_free >= 1) chmax(ndp[i], nxt+1);
				} else {
					chmax(ndp[i], nxt+1);
					if (zcnt_free >= 1) chmax(ndp[i+1], nxt+1);
				}
			}
			if (nxt < len - 1) {
				if (s[nxt] == s[nxt+1]) {
					chmax(ndp[i+(s[nxt] == '0')], nxt+2);
				} else {
					chmax(ndp[i+1], nxt+2);
					chmax(ndp[i], nxt+2);
				}
			}
		}
		dp = move(ndp);
	}
	cout << ans << endl;
	
}

```