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).
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct Z_p {
  using Type = typename decay<decltype(T::value)>::type;
  static vector<Type> MOD_INV;
  constexpr Z_p() : value() {}
  template <typename U>
  Z_p(const U &x) {
    value = normalize(x);
  }
  template <typename U>
  static Type normalize(const U &x) {
    Type v;
    if (-mod() <= x && x < mod())
      v = static_cast<Type>(x);
    else
      v = static_cast<Type>(x % mod());
    if (v < 0) v += mod();
    return v;
  }
  const Type &operator()() const { return value; }
  template <typename U>
  explicit operator U() const {
    return static_cast<U>(value);
  }
  constexpr static Type mod() { return T::value; }
  Z_p &operator+=(const Z_p &otr) {
    if ((value += otr.value) >= mod()) value -= mod();
    return *this;
  }
  Z_p &operator-=(const Z_p &otr) {
    if ((value -= otr.value) < 0) value += mod();
    return *this;
  }
  template <typename U>
  Z_p &operator+=(const U &otr) {
    return *this += Z_p(otr);
  }
  template <typename U>
  Z_p &operator-=(const U &otr) {
    return *this -= Z_p(otr);
  }
  Z_p &operator++() { return *this += 1; }
  Z_p &operator--() { return *this -= 1; }
  Z_p operator++(int) {
    Z_p result(*this);
    *this += 1;
    return result;
  }
  Z_p operator--(int) {
    Z_p result(*this);
    *this -= 1;
    return result;
  }
  Z_p operator-() const { return Z_p(-value); }
  template <typename U = T>
  typename enable_if<is_same<typename Z_p<U>::Type, int>::value, Z_p>::type &
  operator*=(const Z_p &rhs) {
    value = normalize(static_cast<int64_t>(value) *
                      static_cast<int64_t>(rhs.value));
    return *this;
  }
  template <typename U = T>
  typename enable_if<is_same<typename Z_p<U>::Type, int64_t>::value, Z_p>::type
      &
      operator*=(const Z_p &rhs) {
    int64_t q = static_cast<int64_t>(static_cast<long double>(value) *
                                     rhs.value / mod());
    value = normalize(value * rhs.value - q * mod());
    return *this;
  }
  template <typename U = T>
  typename enable_if<!is_integral<typename Z_p<U>::Type>::value, Z_p>::type &
  operator*=(const Z_p &rhs) {
    value = normalize(value * rhs.value);
    return *this;
  }
  template <typename U>
  Z_p &operator^=(U e) {
    if (e < 0) *this = 1 / *this, e = -e;
    Z_p res = 1;
    for (; e; *this *= *this, e >>= 1)
      if (e & 1) res *= *this;
    return *this = res;
  }
  template <typename U>
  Z_p operator^(U e) const {
    return Z_p(*this) ^= e;
  }
  Z_p &operator/=(const Z_p &otr) {
    Type a = otr.value, m = mod(), u = 0, v = 1;
    if (a < (int)MOD_INV.size()) return *this *= MOD_INV[a];
    while (a) {
      Type t = m / a;
      m -= t * a;
      swap(a, m);
      u -= t * v;
      swap(u, v);
    }
    assert(m == 1);
    return *this *= u;
  }
  template <typename U>
  friend const Z_p<U> &abs(const Z_p<U> &v) {
    return v;
  }
  Type value;
};
template <typename T>
bool operator==(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return lhs.value == rhs.value;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
bool operator==(const Z_p<T> &lhs, U rhs) {
  return lhs == Z_p<T>(rhs);
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
bool operator==(U lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) == rhs;
}
template <typename T>
bool operator!=(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return !(lhs == rhs);
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
bool operator!=(const Z_p<T> &lhs, U rhs) {
  return !(lhs == rhs);
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
bool operator!=(U lhs, const Z_p<T> &rhs) {
  return !(lhs == rhs);
}
template <typename T>
bool operator<(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return lhs.value < rhs.value;
}
template <typename T>
bool operator>(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return lhs.value > rhs.value;
}
template <typename T>
bool operator<=(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return lhs.value <= rhs.value;
}
template <typename T>
bool operator>=(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return lhs.value >= rhs.value;
}
template <typename T>
Z_p<T> operator+(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) += rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator+(const Z_p<T> &lhs, U rhs) {
  return Z_p<T>(lhs) += rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator+(U lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) += rhs;
}
template <typename T>
Z_p<T> operator-(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) -= rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator-(const Z_p<T> &lhs, U rhs) {
  return Z_p<T>(lhs) -= rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator-(U lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) -= rhs;
}
template <typename T>
Z_p<T> operator*(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) *= rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator*(const Z_p<T> &lhs, U rhs) {
  return Z_p<T>(lhs) *= rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator*(U lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) *= rhs;
}
template <typename T>
Z_p<T> operator/(const Z_p<T> &lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) /= rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator/(const Z_p<T> &lhs, U rhs) {
  return Z_p<T>(lhs) /= rhs;
}
template <typename T, typename U,
          typename enable_if<is_integral<U>::value>::type * = nullptr>
Z_p<T> operator/(U lhs, const Z_p<T> &rhs) {
  return Z_p<T>(lhs) /= rhs;
}
template <typename T>
istream &operator>>(istream &in, Z_p<T> &number) {
  typename common_type<typename Z_p<T>::Type, int64_t>::type x;
  in >> x;
  number.value = Z_p<T>::normalize(x);
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, const Z_p<T> &number) {
  return out << number();
}
constexpr int mod = 1e9 + 7;
using Zp = Z_p<integral_constant<decay<decltype(mod)>::type, mod>>;
template <typename T>
vector<typename Z_p<T>::Type> Z_p<T>::MOD_INV;
template <typename T = integral_constant<decay<decltype(mod)>::type, mod>>
void precalc_inverse(int SZ) {
  auto &inv = Z_p<T>::MOD_INV;
  if (inv.empty()) inv.assign(2, 1);
  for (; inv.size() <= SZ;)
    inv.push_back(
        (mod - 1LL * mod / (int)inv.size() * inv[mod % (int)inv.size()]) % mod);
}
template <typename T>
vector<T> precalc_power(T base, int SZ) {
  vector<T> res(SZ + 1, 1);
  for (auto i = 1; i <= SZ; ++i) res[i] = res[i - 1] * base;
  return res;
}
template <class T>
struct combinatorics {
  int SZ;
  vector<T> inv, fact, invfact;
  combinatorics(int SZ)
      : SZ(SZ), inv(SZ + 1, 1), fact(SZ + 1, 1), invfact(SZ + 1, 1) {
    for (auto i = 1; i <= SZ; ++i) fact[i] = fact[i - 1] * i;
    invfact[SZ] = 1 / fact[SZ];
    for (auto i = SZ - 1; i >= 0; --i) {
      invfact[i] = invfact[i + 1] * (i + 1);
      inv[i + 1] = invfact[i + 1] * fact[i];
    }
  }
  T C(int n, int k) {
    return n < 0            ? C(-n + k - 1, k) * (k & 1 ? -1 : 1)
           : n < k || k < 0 ? 0
                            : fact[n] * invfact[k] * invfact[n - k];
  }
  T P(int n, int k) { return n < k ? 0 : fact[n] * invfact[n - k]; }
  T H(int n, int k) { return C(n + k - 1, k); }
  T naive_C(long long n, long long k) {
    if (n < k) return 0;
    T res = 1;
    k = min(k, n - k);
    for (auto i = n; i > n - k; --i) res *= i;
    return res * invfact[k];
  }
  T naive_P(long long n, int k) {
    if (n < k) return 0;
    T res = 1;
    for (auto i = n; i > n - k; --i) res *= i;
    return res;
  }
  T naive_H(long long n, long long k) { return naive_C(n + k - 1, k); }
  bool parity_C(long long n, long long k) { return n < k ? 0 : (n & k) == k; }
  T Cat(int n, int k, int m = 1) {
    if (m <= 0)
      return 0;
    else if (k >= 0 && k < m)
      return C(n + k, k);
    else if (k < n + m)
      return C(n + k, k) - C(n + k, k - m);
    else
      return 0;
  }
};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(ios::badbit | ios::failbit);
  string s;
  int k;
  cin >> s >> k;
  int n = (int)s.size();
  if (!k) {
    cout << "1\n";
    return 0;
  }
  --k;
  vector<int> dp(n + 1);
  dp[0] = -1;
  combinatorics<Zp> C(n);
  for (auto x = 1; x <= n; ++x) {
    int y = x;
    while (y > 1) {
      y = __builtin_popcount(y);
      ++dp[x];
    }
  }
  Zp res;
  for (auto i = 0, pref = 0; i < n; ++i) {
    if (s[i] & 1) {
      for (auto rem = 0; rem <= n - 1 - i; ++rem) {
        if (dp[pref + rem] == k) {
          res += C.C(n - 1 - i, rem);
        }
      }
      ++pref;
    }
  }
  if (dp[accumulate(s.begin(), s.end(), 0,
                    [&](int x, char c) { return x + c - '0'; })] == k) {
    ++res;
  }
  if (!k) {
    --res;
  }
  cout << res << "\n";
  return 0;
}
