#include <bits/stdc++.h>

using namespace std;

const int MX = 2000, md = 998244353;

char s[MX + 1];
int mn[2 * MX], mx[2 * MX];

void solve(bool inv) {
	static int cnt[MX + 1];
	int n = strlen(s), bal = 0;
	for (int i = 0; i < n; i++) cnt[i + 1] = s[i] - '0';
	for (int k = 2 * n; k > 0; k--) {
		cnt[0] = 0;
		for (int i = 1; i <= (k + 1) / 2; i++)
			if (cnt[i] > 0) {
				cnt[i]--;
				cnt[i - 1]++;
			}
		
		if (inv) cnt[0] ^= 1;
		
		bal += cnt[0];
		(inv ? mn : mx)[2 * n - k] = bal;
	}
}

int dp[2 * MX + 1][2 * MX + 1];

int main() {
	ignore = scanf("%s", s);
	int n = strlen(s);
	
	solve(false);
	
	for (int i = 0; s[i] != 0; i++) s[i] = '2' - (s[i] - '0');
	
	solve(true);
	
	dp[0][0] = 1;
	for (int i = 0; i < 2 * n; i++)
		for (int j = 0; j <= i; j++)
			for (int d = 0; d < 2; d++)
				if (mn[i] <= j + d && j + d <= mx[i]) {
					dp[i + 1][j + d] += dp[i][j];
					dp[i + 1][j + d] %= md;
				}
	
	int ans = accumulate(dp[2 * n], dp[2 * n] + 2 * n + 1, 0ll) % md;
	printf("%d\n", ans);
	
	return 0;
}
