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

Solution:

import javax.xml.bind.DatatypeConverter;
import java.io.*;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;


public class Main {

    public static void main(String[] args) throws Exception {

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws Exception {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

        out.flush();
        out.close();
    }


    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.000000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[1000];

    int mx = 1000;

    void solve() throws IOException, NoSuchAlgorithmException {

        int[][] C = new int[1000+1][1000+1];
        for (int n=0; n<=1000; ++n) {
            C[n][0] = C[n][n] = 1;
            for (int k=1; k<n; ++k) {
                C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
                C[n][k] %= mod;
            }
        }

        String s = in.nextLine();
        char[] a = s.toCharArray();
        int k = in.nextInt();
        n = a.length;

        if (s.length() <= 10)
            mx = Math.min(mx, Integer.valueOf(s, 2));

        dp[0][0] = 1;
        if (a[n-1] == '1') dp[0][1] = 1;

        for (int i = 1; i < n; i++) {
            int pos = n - i - 1;
            dp[i][0] = 1;
            for (int j = 1; j <= 1000; j++) {
                if (a[pos] != '0') {
                    dp[i][j] = C[i][j] + dp[i-1][j-1];
                    dp[i][j] %= mod;
                }
                else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }

        if (k == 0) {

            out.println(1);
            return;
        }

        if (k == 1) {
            out.println(dp[n-1][k] - 1);
            return;
        }

        out.println(f(1, k));
    }

    int[][] dp = new int[1001][1001];

    int f(int x, int k) {

        if (k == 1)
            return dp[n-1][x];

        int ans = 0;

        for (int i = 2; i <= mx; i++)
            if (Integer.bitCount(i) == x) {
                //System.err.println(i);
                ans += f(i, k-1);
                //System.err.println(ans);
                ans %= mod;
            }

        return ans;
    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (b > p.b) return 1;
            if (b < p.b) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}