#include // cout, endl, cin #include // string, to_string, stoi #include // vector #include // min, mai, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include // fiied,setprecision #include // INT_MAi #include // M_PI #include // random_device, mt19937, uniform_int_distribution #include // 正規表現 #include // time #include // ifstream, ofstream #include // array #include // bit #include // chrono #include // span #include // sqrt, sin, cos, tan, asin, acos, atan, atan2 #include // 複素数 // #include using namespace std; #include using namespace atcoder; // using mint = modint1000000007; using mint = modint998244353; //using mint =modint10007; using ll = long long; using ull = unsigned long long; using ld = long double; // 80bit 18桁 #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, 1, 0, -1}; const string DIR = "URDL"; const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int dy8[8] = {1, 1, 0, -1, -1, -1, 0, 1}; // INFに3以上を掛ける、またはint(INF)に1以上を足すとオーバーフローする // 4611686016279904255 cf: LLONG_MAi=9223372036854775807 const ll INF = (1ll << 62) - (1ll << 31) - 1ll; const int mod=998244353; struct combination { vector 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 || k > n) return 0; return fact[n]*ifact[k]*ifact[n-k]; } }; int main(){ string s; cin>>s; int n=s.size(); combination c(n+5); int cnt=0; mint ans=0; rep(i,n){ if(s[i]=='M')cnt++; else{ rep(i,cnt+1){ //cerr<<":"<