from enum import IntEnum, auto # ステート遷移 class E(IntEnum): S = 0 # S L = auto() # L U = auto() # U R = auto() # R def nexts(self): match self: case E.S: return [E.L, E.U, E.R] case E.L: return [E.L, E.U, E.R] case E.U: return [E.L, E.U, E.R] case E.R: return [E.U, E.R] assert False @staticmethod def states(): for fm in E: for to in fm.nexts(): yield fm, to def is_match(c: str, to) -> bool: match c: case '.': return True case 'L': return to == E.L case 'U': return to == E.U case 'R': return to == E.R assert False MOD = 998244353 N = int(input()) S = input() dp = [[0] * len(E) for _ in range(N+1)] dp[0][E.S] = 1 for i, c in enumerate(S): for fm, to in E.states(): if dp[i][fm] == 0: continue if not is_match(c, to): continue dp[i+1][to] += dp[i][fm] dp[i+1][to] %= MOD ans = sum(dp[N]) % MOD print(ans)