use std::io::*; const MOD: i64 = 998244353; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let s: Vec = itr.next().unwrap().chars().collect(); let mut dp: Vec>> = vec![vec![vec![0; 27]; 27]; n + 1]; dp[0][26][26] = 1; for i in 0..n { for j in 0..=26 { for k in 0..=26 { if s[i] == '?' { for l in 0..26 { if l == j || l == k { continue; } dp[i + 1][l][j] += dp[i][j][k]; dp[i + 1][l][j] %= MOD; } } else { let c = (s[i] as u8 - 'a' as u8) as usize; if c == j || c == k { continue; } dp[i + 1][c][j] += dp[i][j][k]; dp[i + 1][c][j] %= MOD; } } } } let mut ans = 0i64; for i in 0..26 { for j in 0..26 { ans += dp[n][i][j]; ans %= MOD; } } println!("{}", ans); }