#include using namespace std; #include using namespace atcoder; using mint = modint998244353; int main () { string s; cin >> s; int N = s.size(); std::vector pw(N); pw[0] = 1; for (int i = 1; i < N; i ++) { pw[i] = pw[i-1] + ((mint)2).pow(i); } mint ans = 0; int c = 0; for (auto& a : s) { if (a == 'M') { c ++; } else { ans += pw[c]; c = 0; } } cout << ans.val() << endl; }