#include #include using namespace std; using ll = long long; using mint = atcoder::modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; while(!s.empty() && s.back() == 'B') s.pop_back(); if(s.empty()){ cout << "1\n"; return 0; } int n = s.size(); reverse(s.begin(), s.end()); vector tb(n + 1); tb[0] = 1; int l = 0, r = 0; for(int i = 0; i < n; i++){ for(int j = r; j >= l; j--) tb[j + 1] += tb[j]; r++; if(s[i] == 'B') l++; } cout << tb[l].val() << '\n'; }