//In the name of God

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int N = 4e3+10 , mod = 998244353;

int dp[N][N] , b[N] , r[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   string s;
   cin >> s;
   int n = s.length();
   for(int i = 0 ; i < n ; i++){
      b[i] += s[i] - '0' , r[i] += 2 - s[i] + '0';
      if(s[i] == '2')
         b[i]-- , b[i + 1]++;
      else if(s[i] == '0')
         r[i]-- , r[i + 1]++;
      if(i) b[i] += b[i - 1] , r[i] += r[i - 1];
      //cout << r[i] << " " << b[i] << endl;
   }
   b[n] += b[n - 1];
   r[n] += r[n - 1];
   dp[0][0] = 1;
   for(int i = 1 ; i <= 2 * n ; i++){
      for(int j = 0 ; j <= i ; j++){
         if(b[min(i - 1 , n)] >= j && r[min(i - 1 , n)] >= i - j){
            dp[i][j] = dp[i - 1][j];
            if(j > 0)
               (dp[i][j] += dp[i - 1][j - 1]) %= mod;
         }
         //cout << i << " " << j << " " << dp[i][j] << endl;
      }
   }
   cout << dp[2 * n][b[n]];
   return 0;
}
