Problem:
Score : 800 points

Problem Statement

Given is a string S consisting of 0 and 1. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):

Choose a pair of integers i, j (1\leq i < j\leq |S|) such that the i-th and j-th characters of S are 0 and 1, respectively. Remove the j-th character from S and insert it to the immediate left of the i-th character.

Constraints

1 \leq |S| \leq 300

0 \leq K \leq 10^9

S consists of 0 and 1.

Input

Input is given from Standard Input in the following format:

S K

Output

Find the number of strings, modulo 998244353, that can result from applying the operation on S between 0 and K times (inclusive).

Sample Input 1

0101 1

Sample Output 1

4

Four strings, 0101, 0110, 1001, and 1010, can result.

Sample Input 2

01100110 2

Sample Output 2

14

Sample Input 3

1101010010101101110111100011011111011000111101110101010010101010101 20

Sample Output 3

113434815

Solution in Fortran (GNU Fortran 9.2.1) (judge verdict: Runtime Error)

program shift
  implicit none
  integer(8), parameter :: p = 998244353
  character(300) :: s
  integer :: k, n, c(300) = 0, m = 0, i, j, x = 0
  integer(8) :: dp(0:300, 0:300) = 0
  integer(8) :: ans = 0
  read(*,*) s, k
  n = len_trim(s)
  do i = 1, n
    if (s(i:i) == '0') m = m + 1
  end do
  if (m == 0 .or. m == n) then
    write(*,'(i0)') 0
    stop
  end if
  m = m + 1
  j = m
  do i = n, 1, -1
    if (s(i:i) == '0') then
      j = j - 1
    else
      c(j) = c(j) + 1
    end if
  end do
  dp(m, 0) = 1
  x = c(m)
  do i = m - 1, 0, -1
    do j = x, 0, -1
      dp(i, j) = mod(sum(dp(i + 1, max(j - k, 0):j)), p)
    end do
    x = x + c(i)
  end do
  write(*,'(i0)') sum(dp(0, 1:k))
end program shift