#define MD 998244353 string@s; Mint z,w=1; for(char c:s){ if(c=='M'){ w*=3; }else{ z+=w; } } wt(z);