#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#include<memory>

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
using Graph=vector<vector<int>>;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}
//1. maskの部分集合を列挙する
	// 	a. i==0を評価しない
	// 	for(int i=mask; i>0; i=(i-1)&mask) {
	// 	}

	// b. i==0を評価する
	// 	for(int i=mask; i>=0; i--) {
	// 		i&=mask;
	// 	}
// 2. maskを含む集合を列挙する

// 少し目的は変わりますが同じようなやり方でできる処理が、maskを含む集合の列挙です。

// 	for(int i=mask; i<(1<<n); i=(i+1)|mask) {
// 	}

	
using ll = long long int;


///02020
//02110
//02200
//03010
//03100
//04000
//20020
//11020
//11110
//11200
//12010
//12100
//13000
//22020
const ll mod=998244353;
vector<vector<ll>>calc(vector<vector<ll>>v,bool flag=false){
    if(!flag){
        vector<vector<ll>>sums(v.size(),vector<ll>(v[0].size()+1));
        for(int y=0;y<v.size();++y){
            for(int x=0;x<v[0].size();++x){
                sums[y][x+1]+=v[y][x];
                sums[y][x+1]+=sums[y][x];

                sums[y][x+1]%=mod;
            }
        }
        return sums;
    }else{
        vector<vector<ll>>sums(v.size()+1,vector<ll>(v[0].size()+1));
        for(int y=0;y<v.size();++y){
            for(int x=v[0].size();x>=1;--x){
                sums[y+1][x-1]+=v[y][x-1];
                sums[y+1][x-1]+=sums[y][x];

                sums[y+1][x-1]%=mod;
            }
        }
        return sums;
    }
}
int main() {
	ios::sync_with_stdio(false);
    cin.tie();
    string st;
    int K;cin>>st>>K;
    vector<int>v{0};
    for(int i=0;i<st.size();++i){
        if(st[i]=='1'){
            v.back()++;
        }else{
            v.push_back(0);
        }
    }
    int one_num=int(st.size())-int(v.size());
    one_num++;
    one_num=min(one_num,K);
    vector<vector<vector<ll>>>dp(v.size()+1,vector<vector<ll>>(one_num+1,vector<ll>(one_num+1)));

    //WHATS(v)
    dp[int(v.size())][one_num][0]=1ll;
    vector<vector<ll>>sums1=calc(dp.back(),false);
    vector<vector<ll>>sums2=calc(dp.back(),true);
    
    for(int x=int(v.size());x>=1;--x){
        //WHATS(dp[x])
        //if(x<v.size()-20)break;
   // WHATS(sums1)
   // WHATS(sums2)
        int xx=v[x-1];
        for(int rest_move=0;rest_move<=one_num;++rest_move){
            for(int carry=0;carry<=one_num;++carry){

                // for(int kk=0;kk<=one_num;++kk){
                //     int l=0;
                //     int r=one_num-carry;
                //     if(carry+kk<=one_num)dp[x-1][rest_move][carry]+=dp[x][rest_move][carry+kk];

                // }
                int al=0;
                int ar=one_num-carry;
                dp[x-1][rest_move][carry]+=mod+sums1[rest_move][carry+ar+1]-sums1[rest_move][carry];

                // if(dp[x-1][rest_move][carry]<0){
                //     WHATS(dp[x-1][rest_move][carry])
                //     WHATS(al)
                //     WHATS(ar)
                //     assert(false);
                // }
                // for(int kk=1;kk<=min(xx,carry);++kk){
                //     int l=1;
                //     int r=min(xx,carry);
                //     r=min(r,one_num-rest_move);
                //     if(rest_move+kk<=one_num)dp[x-1][rest_move][carry]+=dp[x][rest_move+kk][carry-kk];
                // }
                al=1;
                ar=min(xx,carry);
                ar=min(ar,one_num-rest_move);
                //WHATS(ar)
                if(ar>=al){
                   // WHATS(ar)
                    //WHATS(al)
                    //WHATS(rest_move)
                    //WHATS(carry)
                    dp[x-1][rest_move][carry]+=mod+sums2[rest_move+ar+1][carry-ar]-sums2[rest_move+al][carry-al+1];

                }
                // if(dp[x-1][rest_move][carry]<0){
                //     WHATS(dp[x-1][rest_move][carry])
                //     WHATS(al)
                //     WHATS(ar)
                //     assert(false);
                // }
                dp[x-1][rest_move][carry]%=mod;

            }
        }
        sums1=calc(dp[x-1],false);
        sums2=calc(dp[x-1],true);
    }
    //WHATS(v)
    //WHATS(dp)

    ll answer=0;
    for(int i=0;i<=one_num;++i)answer+=dp[0][i][0];
    answer%=mod;
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 31568