#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

template<int mod>
struct ModInt{
	int x;
	ModInt () : x(0) {}
	ModInt (int64_t x) : x(x >= 0 ? x % mod : (mod - -x % mod) % mod) {}
	ModInt &operator += (const ModInt &p){
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator -= (const ModInt &p) {
		if ((x += mod - p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt &operator *= (const ModInt &p) {
		x = (int64_t) x * p.x % mod;
		return *this;
	}
	ModInt &operator /= (const ModInt &p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt &operator ^= (int64_t p) {
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator - () const { return ModInt(-x); }
	ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
	ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
	ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
	ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
	ModInt operator ^ (int64_t p) const { return ModInt(*this) ^= p; }
	bool operator == (const ModInt &p) const { return x == p.x; }
	bool operator != (const ModInt &p) const { return x != p.x; }
	explicit operator int() const { return x; }
	ModInt &operator = (const int p) { x = p; return *this;}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			a -= t * b;
			std::swap(a, b);
			u -= t * v;
			std::swap(u, v);
		}
		return ModInt(u);
	}
	friend std::ostream & operator << (std::ostream &stream, const ModInt<mod> &p) {
		return stream << p.x;
	}
	friend std::istream & operator >> (std::istream &stream, ModInt<mod> &a) {
		int64_t x;
		stream >> x;
		a = ModInt<mod>(x);
		return stream;
	}
};

template<int mod> struct MComb {
	using mint = ModInt<mod>;
	std::vector<mint> fact;
	std::vector<mint> inv;
	MComb (int n) { // O(n + log(mod))
		fact = std::vector<mint>(n + 1, 1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * mint(i);
		inv.resize(n + 1);
		inv[n] = fact[n] ^ (mod - 2);
		for (int i = n; i--; ) inv[i] = inv[i + 1] * mint(i + 1);
	}
	mint ncr(int n, int r) {
		return fact[n] * inv[r] * inv[n - r];
	}
	mint npr(int n, int r) {
		return fact[n] * inv[n - r];
	}
	mint nhr(int n, int r) {
		assert(n + r - 1 < (int) fact.size());
		return ncr(n + r - 1, r);
	}
};

typedef ModInt<998244353> mint;

int main() {
	std::string s;
	std::cin >> s;
	std::vector<int> all;
	s.push_back('0');
	int cnt = 0;
	for (auto i : s) {
		if (i == '1') cnt++;
		else all.push_back(cnt), cnt = 0;
	}
	
	int n = all.size();
	int sum[n + 1];
	sum[0] = 0;
	for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + all[i];
	int num = sum[n];
	
	int k = ri();
	
	mint dp[num + 1][num * 2 + 1]; // used, diff
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		mint next[num + 1][num * 2 + 1];
		mint r0[num + 1][num * 2 + 1];
		mint r1[num + 1][num * 2 + 1];
		for (int j = 0; j <= num; j++) for (int k = 0; k <= num * 2; k++) {
			if (dp[j][k] == 0) continue;
			// [j, j + all[i])
			// next[l][k + all[i] + j - l] += dp[j][k]
			r0[j][k + all[i] + j - j] += dp[j][k];
			if (j + all[i] <= num) {
				r0[j + all[i]][k + all[i] + j - (j + all[i])] -= dp[j][k];
				// [j + all[i], num]
				// next[l][l - j - all[i] + k] += dp[j][k]
				r1[j + all[i]][j + all[i] - j - all[i] + k] += dp[j][k];
			}
			/*
			for (int l = j; l <= num; l++) {
				assert(k + std::abs(l - j - all[i]) <= num * 2);
				next[l][k + std::abs(l - j - all[i])] += dp[j][k];
			}*/
		}
		for (int j = 0; j <= num; j++) for (int k = 0; k <= num * 2; k++) {
			if (j < num && k) r0[j + 1][k - 1] += r0[j][k];
			if (j < num && k < num * 2) r1[j + 1][k + 1] += r1[j][k];
			next[j][k] += r0[j][k] + r1[j][k];
		}
		for (int j = 0; j <= num; j++) {
			for (int k = 0; k <= num * 2; k++) {
				dp[j][k] = j >= sum[i + 1] ? next[j][k] : 0;
			}
		}
	}
	
	mint res = 0;
	for (int i = 0; i <= 2 * k && i <= num * 2; i++) res += dp[num][i];
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 6464