#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
template<unsigned MOD_> struct ModInt {
    static constexpr unsigned MOD = MOD_;
    unsigned x;
    void undef() { x = (unsigned)-1; }
    bool isnan() const { return x == (unsigned)-1; }
    inline int geti() const { return (int)x; }
    ModInt() { x = 0; }
    ModInt(const ModInt &y) { x = y.x; }
    ModInt(int y) { if (y<0 || (int)MOD<=y) y %= (int)MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt(long long y) { if (y<0 || MOD<=y) y %= MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned long long y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt &operator+=(const ModInt y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt y) { if ((x -= y.x) & (1u<<31)) x += MOD; return *this; }
    ModInt &operator*=(const ModInt y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    ModInt &operator/=(const ModInt y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    ModInt operator-() const { return (x ? MOD-x: 0); }

    ModInt inv() const { return pow(MOD-2); }
    ModInt pow(long long y) const {
	ModInt b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    friend ModInt operator+(ModInt x, const ModInt y) { return x += y; }
    friend ModInt operator-(ModInt x, const ModInt y) { return x -= y; }
    friend ModInt operator*(ModInt x, const ModInt y) { return x *= y; }
    friend ModInt operator/(ModInt x, const ModInt y) { return x *= y.inv(); }
    friend bool operator<(const ModInt x, const ModInt y) { return x.x < y.x; }
    friend bool operator==(const ModInt x, const ModInt y) { return x.x == y.x; }
    friend bool operator!=(const ModInt x, const ModInt y) { return x.x != y.x; }
};

constexpr LL MOD = 998244353;
using Mint = ModInt<MOD>;

int N;
char S[311];

bool vis[311][311][311];

Mint dp[311][311][311];

void MAIN() {
    scanf("%s", S);
    N = strlen(S);

    const int zeros = count(S, S+N, '0');
    const int ones = N - zeros;

    dp[0][0][0] = 1;
    REP (i, N+1) {
	REP (a, zeros+1) REP (b, ones+1) if (dp[i][a][b].x) {
	    // push_front 0;
	    if (i < N && S[N-1-i] == '0') {
		dp[i+1][a][b] += dp[i][a][b];
	    } else {
		dp[i][a+1][b] += dp[i][a][b];
	    }
	    // push_front 1;
	    if (i < N && S[N-1-i] == '1') {
		dp[i+1][a][b] += dp[i][a][b];
	    } else {
		dp[i][a][b+1] += dp[i][a][b];
	    }
	}
    }

    for (int i=N; i>=1; i--) {
	int c0 = 0, c1 = 0;
	if (S[N-i] == '0') c0++;
	else c1++;
	REP (a, zeros+1) REP (b, ones+1) if (dp[i][a][b].x) {
	    dp[i-1][a+c0][b+c1] += dp[i][a][b];
	}
    }



    Mint ans = 1;
    vis[0][0][0] = true;
    REP (t, N) {
	// len = N-1-t;
	
	// S[t+a+b .. );
	REP (a, t+1) REP (b, t+1) if (vis[t][a][b]) {
	    if (t+a+b+2<=N) {
		int c0 = 0, c1 = 0;
		REP (h, 2) {
		    if (S[t+a+b+h] == '0') c0++;
		    else c1++;
		}

		if (c0) {
		    vis[t+1][a+c0-1][b+c1] = true;
		}
		if (c1) {
		    vis[t+1][a+c0][b+c1-1] = true;
		}
	    }

	    if (a+b >= 1 && t+a+b+1<=N) {
		int c0 = 0, c1 = 0;
		if (S[t+a+b] == '0') c0++;
		else c1++;

		if (c0 || a) {
		    vis[t+1][a+c0-1][b+c1] = true;
		}
		if (c1 || b) {
		    vis[t+1][a+c0][b+c1-1] = true;
		}
	    }

	    if (a+b >= 2) {
		if (a) {
		    vis[t+1][a-1][b] = true;
		}
		if (b) {
		    vis[t+1][a][b-1] = true;
		}
	    }
	}

	for (int a=t+1; a>=0; a--) for (int b=t+1; b>=0; b--) if (vis[t+1][a][b]) {
	    int idx = t+a+b+1;
	    assert(idx <= N);

	    if (a && S[t+a+b] == '0') {
		vis[t+1][a-1][b] = true;
	    }
	    if (b && S[t+a+b] == '1') {
		vis[t+1][a][b-1] = true;
	    }


	    if (idx > N) {
		// NOP;
	    } else if (idx < N
		    && ((S[idx] == '0' && vis[t+1][a+1][b])
			|| (S[idx] == '1' && vis[t+1][a][b+1]))) {
		// NOP;
	    } else {
		// S[idx .. N);
		//eprintf("erase = %d, [%s] zero:%d one:%d way:%d\n",
		//	t+1, S+idx, a, b, dp[N-idx][a][b].geti());
		ans += dp[N-idx][a][b];

	    }
	}
    }

    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    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
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
template<unsigned MOD_> struct ModInt {
    static constexpr unsigned MOD = MOD_;
    unsigned x;
    void undef() { x = (unsigned)-1; }
    bool isnan() const { return x == (unsigned)-1; }
    inline int geti() const { return (int)x; }
    ModInt() { x = 0; }
    ModInt(const ModInt &y) { x = y.x; }
    ModInt(int y) { if (y<0 || (int)MOD<=y) y %= (int)MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt(long long y) { if (y<0 || MOD<=y) y %= MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned long long y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt &operator+=(const ModInt y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt y) { if ((x -= y.x) & (1u<<31)) x += MOD; return *this; }
    ModInt &operator*=(const ModInt y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    ModInt &operator/=(const ModInt y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    ModInt operator-() const { return (x ? MOD-x: 0); }

    ModInt inv() const { return pow(MOD-2); }
    ModInt pow(long long y) const {
	ModInt b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    friend ModInt operator+(ModInt x, const ModInt y) { return x += y; }
    friend ModInt operator-(ModInt x, const ModInt y) { return x -= y; }
    friend ModInt operator*(ModInt x, const ModInt y) { return x *= y; }
    friend ModInt operator/(ModInt x, const ModInt y) { return x *= y.inv(); }
    friend bool operator<(const ModInt x, const ModInt y) { return x.x < y.x; }
    friend bool operator==(const ModInt x, const ModInt y) { return x.x == y.x; }
    friend bool operator!=(const ModInt x, const ModInt y) { return x.x != y.x; }
};

constexpr LL MOD = 998244353;
using Mint = ModInt<MOD>;

int N;
char S[311];

bool vis[311][311][311];

Mint dp[311][311][311];

void MAIN() {
    scanf("%s", S);
    N = strlen(S);

    const int zeros = count(S, S+N, '0');
    const int ones = N - zeros;

    dp[0][0][0] = 1;
    REP (i, N+1) {
	REP (a, zeros+1) REP (b, ones+1) if (dp[i][a][b].x) {
	    // push_front 0;
	    if (i < N && S[N-1-i] == '0') {
		dp[i+1][a][b] += dp[i][a][b];
	    } else {
		dp[i][a+1][b] += dp[i][a][b];
	    }
	    // push_front 1;
	    if (i < N && S[N-1-i] == '1') {
		dp[i+1][a][b] += dp[i][a][b];
	    } else {
		dp[i][a][b+1] += dp[i][a][b];
	    }
	}
    }

    for (int i=N; i>=1; i--) {
	int c0 = 0, c1 = 0;
	if (S[N-i] == '0') c0++;
	else c1++;
	REP (a, zeros+1) REP (b, ones+1) if (dp[i][a][b].x) {
	    dp[i-1][a+c0][b+c1] += dp[i][a][b];
	}
    }



    Mint ans = 1;
    vis[0][0][0] = true;
    REP (t, N) {
	// len = N-1-t;
	
	// S[t+a+b .. );
	REP (a, t+1) REP (b, t+1) if (vis[t][a][b]) {
	    if (t+a+b+2<=N) {
		int c0 = 0, c1 = 0;
		REP (h, 2) {
		    if (S[t+a+b+h] == '0') c0++;
		    else c1++;
		}

		if (c0) {
		    vis[t+1][a+c0-1][b+c1] = true;
		}
		if (c1) {
		    vis[t+1][a+c0][b+c1-1] = true;
		}
	    }

	    if (a+b >= 1 && t+a+b+1<=N) {
		int c0 = 0, c1 = 0;
		if (S[t+a+b] == '0') c0++;
		else c1++;

		if (c0 || a) {
		    vis[t+1][a+c0-1][b+c1] = true;
		}
		if (c1 || b) {
		    vis[t+1][a+c0][b+c1-1] = true;
		}
	    }

	    if (a+b >= 2) {
		if (a) {
		    vis[t+1][a-1][b] = true;
		}
		if (b) {
		    vis[t+1][a][b-1] = true;
		}
	    }
	}

	for (int a=t+1; a>=0; a--) for (int b=t+1; b>=0; b--) if (vis[t+1][a][b]) {
	    int idx = t+a+b+1;
	    assert(idx <= N);

	    if (a && S[t+a+b] == '0') {
		vis[t+1][a-1][b] = true;
	    }
	    if (b && S[t+a+b] == '1') {
		vis[t+1][a][b-1] = true;
	    }


	    if (idx > N) {
		// NOP;
	    } else if (idx < N
		    && ((S[idx] == '0' && vis[t+1][a+1][b])
			|| (S[idx] == '1' && vis[t+1][a][b+1]))) {
		// NOP;
	    } else {
		// S[idx .. N);
		//eprintf("erase = %d, [%s] zero:%d one:%d way:%d\n",
		//	t+1, S+idx, a, b, dp[N-idx][a][b].geti());
		ans += dp[N-idx][a][b];

	    }
	}
    }

    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


```