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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long dp[1005];
long long fact[1005];
long long denfact[1005];
long long power(long long base, long long p) {
  if (p == 0) return 1;
  if (p == 1) return base % 1000000007;
  long long val = power(base, p / 2) % 1000000007;
  val = (val * val) % 1000000007;
  if (p % 2 == 1) {
    val = (val * base) % 1000000007;
  }
  return val;
}
int main() {
  dp[1] = 0;
  dp[2] = 1;
  for (long long i = 3; i <= 1000; i++) {
    long long temp = i;
    long long cnt = 0;
    while (temp) {
      temp &= (temp - 1);
      cnt++;
    }
    dp[i] = 1 + dp[cnt];
  }
  fact[1] = 1;
  fact[0] = 1;
  denfact[1] = 1;
  denfact[0] = 1;
  for (long long j = 2; j <= 1000; j++) {
    fact[j] = (fact[j - 1] * j) % 1000000007;
  }
  for (long long j = 2; j <= 1000; j++) {
    long long temp = power(j, 1000000007 - 2) % 1000000007;
    denfact[j] = (denfact[j - 1] * temp) % 1000000007;
  }
  string str;
  cin >> str;
  long long k;
  cin >> k;
  long long len = str.length();
  if (k == 0) {
    cout << "1";
    return 0;
  }
  if (len == 1) {
    cout << "0";
    return 0;
  }
  long long answer = 0;
  long long ones = 0;
  for (long long f = 0; f < len; f++) {
    if (str[f] == '1') {
      long long left = len - f - 1;
      for (long long p = 0; p <= left; p++) {
        long long temp = ones + p;
        if (temp == 0) continue;
        if (dp[temp] + 1 == k) {
          long long num = fact[left] % 1000000007;
          num = (num * denfact[p]) % 1000000007;
          num = (num * denfact[left - p]) % 1000000007;
          answer = (answer + num) % 1000000007;
        }
      }
      if (f == 0 && k == 1) {
        answer = (answer - 1 + 1000000007) % 1000000007;
      }
      ones++;
    }
  }
  if (dp[ones] + 1 == k) {
    answer++;
  }
  answer = answer % 1000000007;
  cout << answer << endl;
  return 0;
}