#include #include #include using namespace std; using ll = long long; using mint93 = atcoder::modint998244353; int main(){ int n; string s; cin >> n >> s; vector dp(n, vector(3)); if (s[0] == 'L'){ dp[0][0] = 1; } else if (s[0] == 'R'){ dp[0][1] = 1; } else if (s[0] == 'U'){ dp[0][2] = 1; } else { dp[0] = {1, 1, 1}; } for (int i = 1; i < n; i++){ if (s[i] == 'L' || s[i] == '.'){ dp[i][0] += dp[i - 1][0] + dp[i - 1][2]; } if (s[i] == 'R' || s[i] == '.'){ dp[i][1] += dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]; } if (s[i] == 'U' || s[i] == '.'){ dp[i][2] += dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]; } } cout << (dp[n - 1][0] + dp[n - 1][1] + dp[n - 1][2]).val() << endl; }