from collections import defaultdict, deque, Counter
# from functools import cache
# import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
# from more_itertools import distinct_permutations
from heapq import heapify, heappop, heappush
import math
import bisect
# from pprint import pprint
from random import randint, shuffle, randrange
# from sortedcontainers import SortedSet, SortedList, SortedDict
import sys
# sys.setrecursionlimit(2000000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)

#################################################   

N = int(input())
S = input()
dp = [0]*3
if S[0] == "L":
    dp[0] = 1
elif S[0] == "R":
    dp[1] = 1
elif S[0] == "U":
    dp[2] = 1
else:
    dp[0] = 1
    dp[1] = 1
    dp[2] = 1

for i in range(1, N):
    s = S[i]
    ndp = [0]*3
    if s == "L":
        ndp[0] = dp[0]+dp[2]
    elif s == "R":
        ndp[1] = dp[0]+dp[1]+dp[2]
    elif s == "U":
        ndp[2] = dp[0]+dp[1]+dp[2]
    else:
        ndp[0] = dp[0]+dp[2]
        ndp[1] = dp[0]+dp[1]+dp[2]
        ndp[2] = dp[0]+dp[1]+dp[2]
    dp = ndp
    dp[0] %= mod2
    dp[1] %= mod2
    dp[2] %= mod2
print(sum(dp)%mod2)