N = int(input()) S = list(input()) DP = [0]*3 mod = 998244353 v = list('LRU.').index(S[0]) if v==3: DP=[1]*3 else: DP[v]=1 for s in S[1:]: NDP = [0]*3 if s=='L' or s=='.': NDP[0]=(DP[0]+DP[2])%mod if s=='R' or s=='.': NDP[1]=sum(DP)%mod if s=='U' or s=='.': NDP[2]=sum(DP)%mod DP = NDP print(sum(DP)%mod)