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).
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    long MOD = 1000000007L;
    public class Obj implements Comparable<Obj>{
        public int t;
        public int h;
        
        public Obj(int t_, int h_){
            t = t_;
            h = h_;
        }
        
        public int compareTo(Obj other){
            return t - other.t;
        }
        
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
        Codechef cf = new Codechef();
        cf.Solve();
	}
	
	int[][] tree;
	int[] lazy;
	
	long[] fac;
	
	public int GCD(int a, int b){
	    while (b > 0){
	        int tmp = b;
	        b = a % b;
	        a = tmp;
	    }
	    return a;
	}
	
	public void Solve(){
        MyScanner sc = new MyScanner();
        String s = sc.nextLine();
        char[] arr = s.toCharArray();
        int n = arr.length;
        int k = sc.nextInt();
        if (k == 0){
            System.out.println(1);
            return;
        }
        int[] dp = new int[1005];
        fac = new long[1005];
        dp[1] = 1;
        fac[1] = 1L;
        fac[0] = 1L;
        for (int i = 2; i <= n; ++i){
            int z = calNum1(i);
            dp[i] = dp[z] + 1;
            fac[i] = (fac[i-1] * (long) i ) % MOD;
        }
        
        ArrayList<Integer> arrB = new ArrayList<Integer>();
        for (int i = 1; i <= n; ++i){
            // System.out.println(i + " " + dp[i]);
            if (dp[i] == k){
                arrB.add(i);
            }
        }
        
        long res = 0L;
        
        for (int a : arrB){
            if (k != 1)
                res = (res + Find(arr, n, a)) % MOD;
            else{
                res = (res + Find(arr, n, a) + MOD - 1) % MOD;
            }
        }
        
        
        out = new PrintWriter(new BufferedOutputStream(System.out));
        out.println(res);
        out.close();
	}
	
	public int calNum1(int z){
	    int res = 0;
	    while (z > 0){
	        if (z % 2 != 0){
	            res++;
	        }
	        z /= 2;
	    }
	    return res;
	}
	
	
	public long Find(char[] arr, int n, int num){
	    int cur = 0;
	    long res = 0L;
	    for (int i = 0; i < n; ++i){
	        if (arr[i] == '1'){
	            if (i < (n-1)){
    	            int rem = n - i - 1;
    	            if (rem >= num){
    	                res = (res + C(rem, num)) % MOD;   
    	            }
    	           // System.out.println(rem + " num: " + num + " curRes: " + res);
    	        }
	            cur++;
	            num--;
	            if (num == 0){
	                res = (res + 1L) % MOD;
	                break;
	            }
	        }
	    }
	   // System.out.println("total: " + res);
	    return res;
	}
	
	
	long pow(int a, int b){
	    long x=1L;
	    long y=(long)a; 
        while(b > 0)
        {
            if(b%2 == 1)
            {
                x=(x*y);
                if(x>MOD) x%=MOD;
            }
            y = (y*y);
            if(y>MOD) y%=MOD; 
            b /= 2L;
        }
        return x;
	}
	
	public long InverseEuler(int n){
	    return pow(n, (int)(MOD - 2L));
	}
	
	public long C(int n, int k){
	    long p1 = InverseEuler((int)fac[k]);
	    long p2 = InverseEuler((int)fac[n-k]);
	    long p3 = (p1 * p2) % MOD;
	    long res = (fac[n] * p3) % MOD;
	   // System.out.println("---C n: " + n + " k: " + k + " res: " + res);
	    return res;
	}
	

	//-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
      try {
         str = br.readLine();
      } catch (IOException e) {
         e.printStackTrace();
      }
      return str;
      }

   }
}