#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define T third
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<pair<int,int>> vp;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvll;
const int C=1e9+7;
void yes(){	
    cout<<"YES\n";
}
void no(){
    cout<<"NO\n";
}
ll binpow(ll a, ll b, ll m=C) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//Variables********************************************

//Functions********************************************

//*****************************************************
void solve(){
	        string s; cin>>s;
    int co{},cx{},cq{};
    for(int i=0;i<10;i++){
        if(s[i]=='o') co++;
        else if(s[i]=='x') cx++;
        else if(s[i]=='?') cq++;
    }
    if(co+cq==0||co>4){
        cout<<0<<endl;
        return;
    }
    int f=co+cq;
    int T=f*f*f*f;
    int x{};
    int prevf=1;
    int p=1;
    for(int i=1;i<=co;i++){
    	x+=p*(prevf*(co-i+1)/i)*(f-i)*(f-i)*(f-i)*(f-i);
    	prevf=prevf*(co-i+1)/i;
    	p*=-1;
    }
    cout<< T-x<<endl;
	
}

signed main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t=1;// cin>>t;
    int x{};
    while(t--){
    	//cout<<"Case #"<<x<<": "; x++;
        solve();
    }
}

#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define efo(i,q) for(int i=0;i<(int)B[q].size();++i)
using namespace std;
typedef long long LL;
const int N=200500,mo=998244353;
int read(int &n)
{
	bool q=0;n=0;char ch=' ';
	for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
	if(ch=='-')ch=getchar(),q=1;
	for(;ch>='0'&&ch<='9';ch=getchar())n=(n<<3)+(n<<1)+ch-48;
	return q?n=-n:n;
}
int n,m,ans;
vector<int>B[N];
void link(int q,int w)
{
	B[q].push_back(w);
	B[w].push_back(q);
}
bool z[N];
void dfs(int q)
{
	z[q]=1;
	efo(i,q)if(!z[B[q][i]])dfs(B[q][i]);
}
int main()
{
	int q,w,_;
	read(n);
	fo(i,1,n)
	{
		read(q);
		link(q,i);
	}
	fo(i,1,n)if(!z[i])
	{
		++ans;
		dfs(i);
	}
	LL t=1;
	fo(i,1,ans)t=(t<<1)%mo;
	printf("%lld\n",t-1);
	return 0;
}