Buggy python submission (verdict: Time Limit Exceeded):
s,k = input().split()
mod = 998244353
k = int(k)
k = min(200,k)
raw = [0]
l = len(s)
for i in range(l):
  if s[i] == '0':
    raw.append(0)
  else:
    raw[-1] += 1
#print(raw)
now = [[0 for _ in range(k+1)] for _ in range(k+1)]
l = len(raw)
raw.reverse()
#print(raw)
now[0][0] = 1
for x in raw:
  last = now[:]
  now = [[0 for _ in range(k+1)] for _ in range(k+1)]
  for i in range(k+1):
    for j in range(k+1):
      for mag in range(x+1):
        if mag + i > k or mag + j > k:
          continue
        now[i+mag][j+mag] += last[i][j]
        now[i+mag][j+mag] %= mod
      for dim in range(j):
        now[i][dim] += last[i][j]
        now[i][dim] %= mod
  #print(now)
#print(now)
ans = 0
for i in range(k+1):
  ans += now[i][0]
print(ans%mod)

Fixed submission:
s,k = input().split()
mod = 998244353
k = int(k)
k = min(300,k)
raw = [0]
l = len(s)
for i in range(l):
  if s[i] == '0':
    raw.append(0)
  else:
    raw[-1] += 1
#print(raw)
now = [[0 for _ in range(k+1)] for _ in range(k+1)]
l = len(raw)
raw.reverse()
#print(raw)
now[0][0] = 1
for x in raw:
  last = now[:]
  now = []
  for i in range(k+1):
    use = last[i][:]
    use.reverse()
    cum = []
    for j in range(k+1):
      if cum:
        cum.append(cum[-1]+use[j])
        cum[-1] %= mod
      else:
        cum = [use[0]]
    cum.reverse()
    now.append(cum)
    #print(cum)
  #print('#')
  cum2 = []
  for i in range(k+1):
    cum = [0 for _ in range(i)]
    cum.append(last[i][0])
    #print('%',cum)
    for l in range(i+1,k+1):
      cum.append(cum[-1]+last[l][l-i])
    #print(cum)
    cum2.append(cum)
  for i in range(k+1):
    for j in range(k+1):
      if j > i:
        pass
      now[i][j] += cum2[i-j][i]
      if i - x - 1 >= 0:
        now[i][j] -= cum2[i-j][i-x-1]
      now[i][j] %= mod
  for i in range(k+1):
    for j in range(k+1):
      now[i][j] -= last[i][j]
      now[i][j] %= mod
  #print(now)
  #print('##')
        
  #print(now)
#print(now)
ans = 0
for i in range(k+1):
  ans += now[i][0]
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
s,k = input().split()
mod = 998244353
k = int(k)
k = min(300,k)
raw = [0]
l = len(s)
for i in range(l):
  if s[i] == '0':
    raw.append(0)
  else:
    raw[-1] += 1
#print(raw)
now = [[0 for _ in range(k+1)] for _ in range(k+1)]
l = len(raw)
raw.reverse()
#print(raw)
now[0][0] = 1
for x in raw:
  last = now[:]
  now = [[0 for _ in range(k+1)] for _ in range(k+1)]
  for i in range(k+1):
    for j in range(k+1):
      for mag in range(x+1):
        if mag + i > k or mag + j > k:
          continue
        now[i+mag][j+mag] += last[i][j]
        now[i+mag][j+mag] %= mod
      for dim in range(j):
        now[i][dim] += last[i][j]
        now[i][dim] %= mod
  #print(now)
#print(now)
ans = 0
for i in range(k+1):
  ans += now[i][0]
print(ans%mod)

Fixed submission:
s,k = input().split()
mod = 998244353
k = int(k)
k = min(300,k)
raw = [0]
l = len(s)
for i in range(l):
  if s[i] == '0':
    raw.append(0)
  else:
    raw[-1] += 1
#print(raw)
now = [[0 for _ in range(k+1)] for _ in range(k+1)]
l = len(raw)
raw.reverse()
#print(raw)
now[0][0] = 1
for x in raw:
  last = now[:]
  now = []
  for i in range(k+1):
    use = last[i][:]
    use.reverse()
    cum = []
    for j in range(k+1):
      if cum:
        cum.append(cum[-1]+use[j])
        cum[-1] %= mod
      else:
        cum = [use[0]]
    cum.reverse()
    now.append(cum)
    #print(cum)
  #print('#')
  cum2 = []
  for i in range(k+1):
    cum = [0 for _ in range(i)]
    cum.append(last[i][0])
    #print('%',cum)
    for l in range(i+1,k+1):
      cum.append(cum[-1]+last[l][l-i])
    #print(cum)
    cum2.append(cum)
  for i in range(k+1):
    for j in range(k+1):
      if j > i:
        pass
      now[i][j] += cum2[i-j][i]
      if i - x - 1 >= 0:
        now[i][j] -= cum2[i-j][i-x-1]
      now[i][j] %= mod
  for i in range(k+1):
    for j in range(k+1):
      now[i][j] -= last[i][j]
      now[i][j] %= mod
  #print(now)
  #print('##')
        
  #print(now)
#print(now)
ans = 0
for i in range(k+1):
  ans += now[i][0]
print(ans%mod)