Problem: The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such operation is to take a positive integer x and reduce it to the number of bits set to 1 in the binary representation of x. For example for number 13 it's true that 1310 = 11012, so it has 3 bits set and 13 will be reduced to 3 in one operation.

He calls a number special if the minimum number of operations to reduce it to 1 is k.

He wants to find out how many special numbers exist which are not greater than n. Please help the Travelling Salesman, as he is about to reach his destination!

Since the answer can be large, output it modulo 109 + 7.

Input

The first line contains integer n (1 ≤ n < 21000).

The second line contains integer k (0 ≤ k ≤ 1000).

Note that n is given in its binary representation without any leading zeros.

Output

Output a single integer — the number of special numbers not greater than n, modulo 109 + 7.

Examples

Input

110
2


Output

3


Input

111111011
2


Output

169

Note

In the first sample, the three special numbers are 3, 5 and 6. They get reduced to 2 in one operation (since there are two set bits in each of 3, 5 and 6) and then to 1 in one more operation (since there is only one set bit in 2).

Solution (in PYTHON3):

Solution:
# -*- encoding:utf-8 -*-

import sys
from functools import reduce

#sys.stdin = open('C.in', 'r')
def debug(*args):
    return
    print('debug ',end='')
    for x in args:
        print(x,end=' ')
    print('')

n = input()
k = int(input())
mod = 1000000007
#n = '1'*1000
#k = 5

a = [0] * 1001

def bitnum(x):
    ans = 0
    while x:
        if x & 1: ans += 1
        x >>= 1
    return ans

for i in range(1,1001):
    bn = bitnum(i)
    a[i] = a[bn] + 1

#debug([i for i in range(10)])
#debug(a[:10])

''' number of bits that needs k operations to reduce to 1 '''
a = [i for i in range(len(a)) if a[i]==k]
a = list(filter(lambda x: x <= len(n), a))
#debug(a[:10])

C = [None for i in range(1001)]
C[0] = [1, 0]
for i in range(1, len(C)):
    C[i] = [1] + [(C[i-1][j]+C[i-1][j-1])%mod for j in range(1,i)] + [1]

answer = 0

def cal2(x, arr):
    global answer
    while True:
        ln = len(arr)
        if x == 0:
            answer += 1
            return
        if x > ln: return
        if x == ln:
            if '0' in arr:return
            else:
                answer += 1
                return
        answer += C[ln-1][x]
        answer %= mod
        #debug(ans, x)
        i = arr.find('1', arr.index('1')+1)
        if i < 0: 
            if x == 1: answer += 1
            return
        #debug("***")
        x -= 1
        arr = arr[i:]
        #cal2(x-1, arr[i:])

def cal(x):
    global answer
    answer = 0
    cal2(x, n)
    debug(answer)
    return answer % mod

def solve():
    if k == 0:return 1
    if len(a) == 0:return 0
    tmp = map(cal,a)
    debug(list(tmp))
    ans = reduce(lambda x,y:(x+y)%mod, map(cal, a))
    return ans if k != 1 else ans-1

try:
    print(solve())
except Exception as e:
    print(k, n[-30:])

#print(solve())