package main import . "fmt" func main() { var n int var s string Scan(&n,&s) const m=998244353 var lc,rc,uc int64 for _,x:=range s { switch x { case 'L': lc,rc,uc=lc+uc,0,0 case 'R': lc,rc,uc=0,lc+rc+uc,0 case 'U': lc,rc,uc=0,0,lc+rc+uc case '.': lc,rc,uc=lc+uc,lc+rc+uc,lc+rc+uc } lc,rc,uc=lc%m,rc%m,uc%m } Println((lc+rc+uc)%m) }