#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; using namespace atcoder; using mint = modint998244353; int n; string s; mint dp[200001][3]; //L, R, U signed main() { int i, j, k; cin >> n >> s; vector a(n); rep(i, n) { if (s[i] == '.') a[i] = -1; if (s[i] == 'L') a[i] = 0; if (s[i] == 'R') a[i] = 1; if (s[i] == 'U') a[i] = 2; } dp[0][2] = 1; rep(i, n) { rep(j, 3) { rep(k, 3) { if (a[i] != -1 && k != a[i]) continue; if (j == 1 && k == 0) continue; dp[i + 1][k] += dp[i][j]; } } } /*rep(i, n + 1) { rep(j, 3) { cout << dp[i][j].val() << " "; } cout << endl; }*/ mint ans = 0; rep(i, 3) ans += dp[n][i]; cout << ans.val() << endl; return 0; }