#include #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--) using namespace std; using ll = long long; using ld = long double; const double pi = 3.141592653589793; const long long inf = 2 * 1e9; const long long linf = 4 * 1e18; const ll mod1 = 1000000007; const ll mod2 = 998244353; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } // atcoder #include using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; vector> base = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int main() { ////////////////// ios::sync_with_stdio(false); cin.tie(nullptr); ////////////////// ll N; string S; cin >> N >> S; vector>> dp(3, vector>(2, vector(2))); vector>> next_dp(3, vector>(2, vector(2))); dp[2][0][0] = (S.at(0) != 'x'); dp[2][0][1] = (S.at(0) != 'o'); rep(i, 0, N - 1) { fill(next_dp.begin(), next_dp.end(), vector>(2, vector(2))); if (S.at(i + 1) != 'x') { next_dp[1][0][0] += dp[0][0][0]; next_dp[0][1][0] += dp[0][0][1]; next_dp[1][1][0] += dp[0][1][0]; next_dp[2][0][0] += dp[1][0][0]; next_dp[0][0][0] += dp[1][0][1]; next_dp[2][0][0] += dp[1][1][0]; next_dp[0][1][0] += dp[1][1][1]; next_dp[2][0][0] += dp[2][0][0]; next_dp[0][0][0] += dp[2][0][1]; } if (S.at(i + 1) != 'o') { next_dp[1][0][1] += dp[0][0][1]; next_dp[0][1][1] += dp[0][0][0]; next_dp[1][1][1] += dp[0][1][1]; next_dp[2][0][1] += dp[1][0][1]; next_dp[0][0][1] += dp[1][0][0]; next_dp[2][0][1] += dp[1][1][1]; next_dp[0][1][1] += dp[1][1][0]; next_dp[2][0][1] += dp[2][0][1]; next_dp[0][0][1] += dp[2][0][0]; } swap(dp, next_dp); } mint2 ans = 0; rep(i, 0, 3) rep(j, 0, 2) rep(k, 0, 2) ans += dp[i][j][k]; cout << ans.val() << "\n"; }