#include #include using namespace std; using mint = atcoder::modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n >> s; vector dp(n + 1, vector(3)); dp[0][0] = 1; for(int i = 0; i < n; i++){ for(int j = 0; j < 3; j++){ if(s[i] == 'U'){ dp[i + 1][0] += dp[i][j]; }else if(s[i] == 'R'){ dp[i + 1][1] += dp[i][j]; }else if(s[i] == 'L'){ if(j == 1) continue; dp[i + 1][2] += dp[i][j]; }else{ for(int k = 0; k < 3; k++){ if(j == 1 && k == 2) continue; dp[i + 1][k] += dp[i][j]; } } } } cout << accumulate(dp[n].begin(), dp[n].end(), mint(0)).val() << '\n'; }