#include using namespace std; template using min_priority_queue = priority_queue,greater>; random_device seed_gen; mt19937 engine(seed_gen()); int64_t get_time(){ struct::timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * int64_t(1'000'000'000) + t.tv_nsec; } template void invec(vector &v){ for(auto &i : v) cin >> i; return; } template void outvec(vector &v, string s = " "){ bool b = false; for(auto i : v){ if(b) cout << s; else b = true; cout << i; } cout << endl; return; } template bool chmin(T &a, const T& b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } template bool chmax(T &a, const T& b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template T pow_mod(T a, T b, T n){ a %= n; if(a == 0) return 0; if(a == 1 || b == 0) return 1; if(b == 1) return a; T c = b/2; T d = b%2; T ac = pow_mod(a,c,n); T ad = pow_mod(a,d,n); return ac*ac%n*ad%n; } template T ex_euclid(T a, T b, T &x, T &y){ T d = a; if(b != 0){ d = ex_euclid(b, a%b, y, x); y -= (a/b)*x; } else{ x = 1; y = 0; } //cout << a << " * " << x << " + " << b << " * " << y << " = " << d << endl; return d; } template struct modint{ int64_t val; modint(){ val = 0; } modint(int64_t a){ if(a <= -mod) a %= mod; else if(a >= mod) a %= mod; if(a < 0) a += mod; val = a; } modint inv(){ int64_t x, k; int64_t d = ex_euclid(val, mod, x, k); assert(d == 1); return modint(x); } bool operator==(modint other){ return val == other.val; } bool operator!=(modint other){ return val != other.val; } modint operator+(modint other){ return modint(val + other.val); } modint operator-(modint other){ return modint(val - other.val); } modint operator*(modint other){ return modint(val * other.val); } modint operator/(modint other){ return modint(val * other.inv().val); } void operator+=(modint other){ val += other.val; if(val >= mod) val -= mod; } void operator-=(modint other){ val -= other.val; if(val < 0) val += mod; } void operator*=(modint other){ val *= other.val; val %= mod; } void operator/=(modint other){ val *= other.inv().val; val %= mod; } void operator++(){ val++; if(val >= mod) val -= mod; } void operator--(){ val--; if(val < 0) val += mod; } }; template modint pow(modint a, int64_t b){ using mint = modint; if(b <= -(mod - 1)) b %= mod - 1; else if(b >= (mod - 1)) b %= mod - 1; if(b < 0) b += mod - 1; if(a == 0) return mint(0); if(b == 0) return mint(1); if(a == 1) return mint(1); if(b == 1) return a; mint x = pow(a, b / 2); mint y = pow(a, b % 2); return x * x * y; } template pair>, vector>> init_mod_factorial(int N){ using mint = modint; vector v(N+1); vector v_inv(N+1); for(int i = 0; i <= N; i++){ if(i == 0) v[i] = 1; else v[i] = v[i - 1] * i; } for(int i = N; i >= 0; i--){ if(i == N) v_inv[i] = v[i].inv(); else v_inv[i] = v_inv[i+1] * (i + 1); } return make_pair(v, v_inv); } template modint factorial_mod(int64_t x, pair>, vector>> &factorial_list){ return factorial_list.first[x]; } template modint factorial_inv_mod(int64_t x, pair>, vector>> &factorial_list){ return factorial_list.second[x]; } template modint comb_mod(int64_t x, int64_t y, pair>, vector>> &factorial_list){ if(y < 0 || x < y) return modint(0); return factorial_list.first[x] * factorial_list.second[y] * factorial_list.second[x - y]; } bool yn(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; return b; } bool check_with_simple_solution; bool calc_time; bool random_input; bool debug_output; int num_of_testcase; using ans_type = int; void input(){ if(num_of_testcase > 1){ } if(random_input){ } else{ } return; } void output_input(){ return; } void pre_solve(){ return; } ans_type solve(){ const int64_t mod = 998244353; using mint = modint; int n; cin >> n; string s; cin >> s; vector DP(n+1, vector(3, 0)); DP[0][0] = 1; for(int i = 0; i < n; i++) { char c = s[i]; if(c == 'L' || c == '.') { DP[i+1][0] += DP[i][0] + DP[i][1]; } if(c == 'U' || c == '.') { DP[i+1][1] += DP[i][0] + DP[i][1] + DP[i][2]; } if(c == 'R' || c == '.') { DP[i+1][2] += DP[i][0] + DP[i][1] + DP[i][2]; } } mint ans = DP[n][0] + DP[n][1] + DP[n][2]; cout << ans.val << endl; return ans_type(); } ans_type solve_simple(){ return ans_type(); } void output(ans_type ans){ return; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); check_with_simple_solution = 0; calc_time = 0; random_input = 0; debug_output = 0; num_of_testcase = 1; if(num_of_testcase == 0) cin >> num_of_testcase; pre_solve(); if(check_with_simple_solution){ for(int i = 0; i < num_of_testcase; i++){ if(debug_output) cout << "begin case " << i << " " << string(16, '=') << endl; input(); ans_type ans = solve(); if(debug_output) cout << string(16, '=') << endl; ans_type ans_simple = solve_simple(); if(ans != ans_simple){ cout << "input: " << endl; output_input(); cout << "output: " << endl; output(ans); cout << "expected: " << endl; output(ans_simple); } if(debug_output) cout << "end case " << i << " " << string(16, '=') << endl; } } else{ int64_t time_start = get_time(); for(int i = 0; i < num_of_testcase; i++){ input(); output(solve()); } int64_t time_end = get_time(); if(calc_time){ double time_per_case = (time_end - time_start) / (1e9 * num_of_testcase); cout << fixed << setprecision(3) << time_per_case << "[second/case]" << endl; } } return 0; }