#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=200010;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;


signed main(){
    ll n;
    string s;cin>>n>>s;
    if(n==1){
        cout<<(s[0]=='?'?26:1)<<endl;
        return 0;
    }
    vector<vector<vector<ll> > >dp(n+1,vector<vector<ll> >(26,vector<ll>(26)));
    if(s[0]=='?'){
        if(s[1]=='?'){
            rep(i,26){
                rep(j,26){
                    if(i!=j)dp[2][i][j]=1;
                }
            }
        }else{
            rep(i,26){
                if(i!=s[1]-'a')dp[2][i][s[1]-'a']=1;
            }
        }
    }else{
        if(s[1]=='?'){
            rep(i,26){
                if(i!=s[0]-'a')dp[2][s[0]-'a'][i]=1;
            }
        }else{
            if(s[0]!=s[1])dp[2][s[0]-'a'][s[1]-'a']=1;
        }
    }
    REP(i,2,n){
        rep(j,26){
            rep(k,26){
                if(s[i]=='?'){
                    rep(l,26){
                        if(k!=l&&j!=l)dp[i+1][k][l]=(dp[i+1][k][l]+dp[i][j][k])%mod;
                    }
                }else{
                    ll l=s[i]-'a';
                    if(k!=l&&j!=l)dp[i+1][k][l]=(dp[i+1][k][l]+dp[i][j][k])%mod;
                }
            }
        }
    }
    ll ans=0;
    rep(i,26){
        rep(j,26){
            ans=(ans+dp[n][i][j])%mod;
        }
    }
    cout<<ans<<endl;
}