n = int(input()) s = input() mod = 998244353 # dp[i][j]: s[i - 1]が状態jの時の組み合わせ数 dp = [[0] * 3 for _ in range(n)] c = s[0] if c == ".": dp[0] = [1] * 3 else: dp[0]["LRU".index(c)] = 1 for i in range(1, n): c = s[i] if c in ".L": dp[i][0] = dp[i - 1][0] + dp[i - 1][2] if c in ".R": dp[i][1] = sum(dp[i - 1]) if c in ".U": dp[i][2] = sum(dp[i - 1]) for j in range(3): dp[i][j] %= mod ans = sum(dp[n - 1]) % mod print(ans)