#include<bits/stdc++.h>
#define N 4010 
using namespace std;
string st;
int n,a[N],b[N],dp[N][N],mo=998244353;
int main(){
	cin>>st;n=st.length();
	for (int i=1;i<=n;i++)a[i]=st[i-1]-'0'+a[i-1],b[i]=b[i-1]+'2'-st[i-1];
	dp[0][0]=1;
	for (int i=0;i<=a[n];i++)
		for (int j=0;j<=b[n];j++)
			if (i<=a[min(n,i+j)]&&j<=b[min(n,i+j)])dp[i][j]=(dp[i][j]+(j?dp[i][j-1]:0)+(i?dp[i-1][j]:0))%mo;
	cout<<dp[a[n]][b[n]]<<endl;
	return 0;
}