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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn = 319;
const int MOD = 998244353;
ll dp[maxn][maxn][maxn];
string s; 
int k, ones, zeros;
vi numo, mino;

ll solve(int a, int b, int c){
	if(dp[a][b][c] != -1){
		return dp[a][b][c];
	}
	if(a == 0){
		return (b - c == numo[a]);
	}
	ll ans = 0;
	for(int i = 0; i <= b; i++){
		int nh = b - i; // i is in this column, nh in previous
		if(i - numo[a] > c) break;
		if(nh < mino[a-1]) continue;
		int nm = max(i - numo[a], 0);
		ans = (ans + solve(a-1,nh,c-nm))%MOD;
	}
	dp[a][b][c] = ans;
	//cout << a << " " << b << " " << c << " "  << dp[a][b][c] << endl;
	return ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	cin >> s;
	cin >> k;
	int n = sz(s);
	for(char c: s) if(c == '1') ones++;
	zeros = n - ones;
	rep(i,maxn) rep(j,maxn) rep(ii,maxn) dp[i][j][ii] = -1;
	numo.pb(0);
	for(char c: s){
		if(c == '1') numo.back()++;
		else numo.pb(0);
	}
	mino.resize(sz(numo));
	mino[0] = numo[0];
	for(int i = 1; i < sz(numo); i++){
		mino[i] = mino[i-1] + numo[i];
	}
	ll ans = 0;
	k = min(k, ones);
	rep(i,k+1){
		ans = (ans + solve(zeros,ones,i))%MOD;
	}
	cout << ans << endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 2e3 + 6, MOD = 1e9 + 7;
int n, k;
int F[MAX_N * MAX_N];
int D[MAX_N * MAX_N];
int dp[MAX_N][MAX_N];

int _sum(int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _mul(int a, int b) {
	int res = 1LL * a * b % MOD;
	return res;
}

int _pow(int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);

	return res;
}

int choose(int a, int b) {
	if (b < a || min(a, b) < 0)
		return 0;

	return _mul(F[b], _mul(D[a], D[b - a]));
}

void pre_process() {
	F[0] = 1;
	for (int i = 1; i < MAX_N * MAX_N; i++)
		F[i] = _mul(F[i - 1], i);

	D[0] = 1;
	for (int i = 1; i < MAX_N * MAX_N; i++)
		D[i] = _pow(F[i], MOD - 2);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	pre_process();
	cin >> n >> k;
	
	if (k == 1) {
		cout << "1\n";
		return 0;
	}

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = 1;
		for (int j = 1; j <= i; j++)
			dp[i][j] = _sum(_mul(dp[i][j - 1], choose(k - 2, n * k - i - (j - 1) * (k - 1) - 1)), dp[i - 1][j]);
	}

	cout << _mul(dp[n][n], F[n]) << "\n";
	return 0;
}
