#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(ll i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template bool chmax(T &x, const T &y) {return (x bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;}; constexpr ll MOD=998244353; constexpr ll INF=2e18; int main(){ int n; cin >> n; string s; cin >> s; ll ans=0; VI dp(3,0); dp[0]=1; REP(i,n){ VI ndp(3,0); ndp[0]=1; if(s[i]=='?'){ REP(j,10)REP(k,3){ ndp[(k*10+j)%3]+=dp[k]; ndp[(k*10+j)%3]%=MOD; } } else{ REP(k,3){ ndp[(k*10+s[i]-'0')%3]+=dp[k]; ndp[(k*10+s[i]-'0')%3]%=MOD; } } dp=ndp; ans=(ans+dp[0]-1+MOD)%MOD; } cout << ans << endl; return 0; }