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

Solution (in CPP):

Solution:
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
 
// hloya template v26
 
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
 
#include <bits/stdc++.h>
using namespace std;
 
bool dbg = 0;
  
clock_t start_time = clock();
#define current_time fixed<<setprecision(6)<<(ld)(clock()-start_time)/CLOCKS_PER_SEC
  
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))
 
#define ull unsigned long long
#define ll long long
#define ld long double
#define pii pair<int,int>
#define umap unordered_map<int, int>
 
#define files1 freopen("input.txt","r",stdin)
#define files2 freopen("output.txt","w",stdout)
#define files files1;files2
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
 
// #define endl '\n'
#define ln(i,n) " \n"[(i) == (n) - 1]
 
void bad(string mes = "NO"){cout << mes;exit(0);}
void bad(int mes){cout << mes;exit(0);}
 
template<typename T>
string bin(T x, int st = 2){
    string ans = "";
    while (x > 0){
        ans += char('0' + x % st);
        x /= st;
    }
    reverse(ans.begin(), ans.end());
    return ans.empty() ? "0" : ans;
}
 
mt19937_64 mt_rand(
    chrono::system_clock::now().time_since_epoch().count()
);
 
template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }
 
// inline int popcount(int x){
//     int count = 0;
//     __asm__ volatile("POPCNT %1, %0;":"=r"(count):"r"(x):);
//     return count;
// }
  
template<typename T>
T input(){
    T ans = 0, m = 1;
    char c = ' ';
  
    while (!((c >= '0' && c <= '9') || c == '-')) {
        c = getchar();
    }
  
    if (c == '-')
        m = -1, c = getchar();
    while (c >= '0' && c <= '9'){
        ans = ans * 10 + (c - '0'), c = getchar();
    }
    return ans * m;
}
 
template<typename T>
T gcd (T a, T b) { while (b) { a %= b; swap (a, b); } return a; }
  
template<typename T> void read(T& a) { a = input<T>(); }
template<typename T> void read(T& a, T& b) { read(a), read(b); }
template<typename T> void read(T& a, T& b, T& c) { read(a, b), read(c); }
template<typename T> void read(T& a, T& b, T& c, T& d) { read(a, b), read(c, d); }
 
const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-12;
const int maxn = (int)3e5 + 3, base = 998244353;
const ll llinf = 2e18 + 5;
const int mod = 1e9 + 7;

int binpow (int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res = 1ll * res * a % mod;
        a = 1ll * a * a % mod;
        n >>= 1;
    }
    return res;
}

int dp[305][305][305];
int f[305][305][305]; 
int cnt0[305], cnt1[305];
 
void add(int& x, int y) {
    x = (x + y) % base;
}

int us[600][600];

int main() {
    // files1;
    fast_io;

    string s;
    cin >> s;

    // precalc number of strings from a zers and b ones with max subseq s[i:...]
    f[s.size()][0][0] = 1;

    for (int i = s.size(); i >= 0; i--) {
        for (int a = 0; a < 302; a++) {
            for (int b = 0; b < 302; b++) {
                // adding 0 
                {
                    int ni = i;
                    if (i > 0 && s[i - 1] == '0') {
                        ni--;
                    }
                    add(f[ni][a + 1][b], f[i][a][b]);
                }
                {
                    int ni = i;
                    if (i > 0 && s[i - 1] == '1') {
                        ni--;
                    }
                    add(f[ni][a][b + 1], f[i][a][b]);
                }
            }
        }
    }


    for (int i = 0; i < s.size(); i++) {
        for (int a = 0; a < 302; a++) {
            for (int b = 0; b < 302; b++) {
                add(f[i + 1][a][b], f[i][a][b]);
            }
        }
    }

    for (int i = s.size() - 1; i >= 0; i--) {
        cnt0[i] = cnt0[i + 1] + (s[i] == '0');
        cnt1[i] = cnt1[i + 1] + (s[i] == '1');
    }


    dp[0][0][0] = 1;
    queue<tuple<int, int, int>> q;
    q.push({0, 0, 0});

    int mxsum = 0;

    int ans = 0;
    while (!q.empty()) {
        // dp in queue


        auto [i, l0, l1] = q.front();
        q.pop();


        // cout << s.substr(i) << '|' << l0 << ' ' << l1 << ' ' << "+" << f[i][rl0][rl1] << endl;
        

        mxsum = max(mxsum, l0 + l1);

        if (s.size() - i + l0 + l1 >= 2) {
            for (int k0 = 0; k0 <= min(l0, 2); k0++)
                for (int k1 = 0; k1 <= min(l1, 2) && k0 + k1 <= 2; k1++) {
                    int ks = 2 - k0 - k1;
                    if (i + ks > s.size()) {
                        continue;
                    }

                    int rk0 = k0, rk1 = k1;
                    if (ks >= 1) {
                        rk0 += s[i] == '0';
                        rk1 += s[i] == '1';
                    }                   
                    if (ks >= 2) {
                        rk0 += s[i + 1] == '0';
                        rk1 += s[i + 1] == '1';
                    }

                    if (rk0 > 0) {
                        // leave 0
                        int& to = dp[i + ks][l0 - k0 + 1][l1 - k1];
                        if (to != 1) {
                            to = 1;
                            q.push({i + ks, l0 - k0 + 1, l1 - k1});
                        }
                    }
                    if (rk1 > 0) {
                        int& to = dp[i + ks][l0 - k0][l1 - k1 + 1];
                        if (to != 1) {
                            to = 1;
                            q.push({i + ks, l0 - k0, l1 - k1 + 1});
                        }
                    }
                }    
        }
    }

    for (int i = s.size(); i >= 0; i--) {
        for (int l0 = 0; l0 < 300; l0++)
            for (int l1 = 0; l1 < 300; l1++) {
                int rl0 = l0 + cnt0[i];
                int rl1 = l1 + cnt1[i];
                if (!us[rl0][rl1] && dp[i][l0][l1]) {
                    us[rl0][rl1] = 1;
                    add(ans, f[i][rl0][rl1]);
                }
            }
    }

    cout << ans;
    return 0;
}