from enum import IntEnum, auto from functools import cache class E(IntEnum): S = 0 # 開始 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 @cache def states(): res = [] for fm in E: for to in fm.nexts(): res.append((fm, to)) return res def state_dp(xs: list, op, e, init: dict): dp = [e for _ in range(len(E))] for k, v in init.items(): dp[k] = v for x in xs: pp = [e for _ in range(len(E))] dp, pp = pp, dp for fm, to in E.states(): if not is_valid(to, pp[fm], x): continue dp[to] = op(to, dp[to], fm, pp[fm], x) return dp def is_valid(to: E, fm_v, v) -> bool: match v: case '.': return True case 'L': return to == E.L case 'U': return to == E.U case 'R': return to == E.R assert False def op(to: E, to_v, fm: E, fm_v, v): return (to_v + fm_v) % MOD MOD = 998244353 N = int(input()) S = input() dp = state_dp(S, op, 0, {E.S: 1}) ans = sum(dp) % MOD print(ans)