Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, they invented p-binary numbers of the form 2^x + p, where x is a non-negative integer.

For example, some -9-binary ("minus nine" binary) numbers are: -8 (minus eight), 7 and 1015 (-8=2^0-9, 7=2^4-9, 1015=2^{10}-9).

The boys now use p-binary numbers to represent everything. They now face a problem: given a positive integer n, what's the smallest number of p-binary numbers (not necessarily distinct) they need to represent n as their sum? It may be possible that representation is impossible altogether. Help them solve this problem.

For example, if p=0 we can represent 7 as 2^0 + 2^1 + 2^2.

And if p=-9 we can represent 7 as one number (2^4-9).

Note that negative p-binary numbers are allowed to be in the sum (see the Notes section for an example).

Input

The only line contains two integers n and p (1 ≤ n ≤ 10^9, -1000 ≤ p ≤ 1000).

Output

If it is impossible to represent n as the sum of any number of p-binary numbers, print a single integer -1. Otherwise, print the smallest possible number of summands.

Examples

Input


24 0


Output


2


Input


24 1


Output


3


Input


24 -1


Output


4


Input


4 -7


Output


2


Input


1 1


Output


-1

Note

0-binary numbers are just regular binary powers, thus in the first sample case we can represent 24 = (2^4 + 0) + (2^3 + 0).

In the second sample case, we can represent 24 = (2^4 + 1) + (2^2 + 1) + (2^0 + 1).

In the third sample case, we can represent 24 = (2^4 - 1) + (2^2 - 1) + (2^2 - 1) + (2^2 - 1). Note that repeated summands are allowed.

In the fourth sample case, we can represent 4 = (2^4 - 7) + (2^1 - 7). Note that the second summand is negative, which is allowed.

In the fifth sample case, no representation is possible.
#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int N = 0;
  register char c = getchar_unlocked();
  while (c < 48 || c > 57) {
    c = getchar_unlocked();
  }
  while (c > 47 && c < 58) {
    N = (N << 3) + (N << 1) + (c - 48);
    c = getchar_unlocked();
  }
  return N;
}
inline long long int inl() {
  long long int N = 0;
  register char c = getchar_unlocked();
  while (c < 48 || c > 57) {
    c = getchar_unlocked();
  }
  while (c > 47 && c < 58) {
    N = (N << 3) + (N << 1) + (c - 48);
    c = getchar_unlocked();
  }
  return N;
}
inline int inp() {
  int N = 0, sign = 1;
  register char c = getchar_unlocked();
  while (c < 48 || c > 57) {
    if (c == '-') sign = 0;
    c = getchar_unlocked();
  }
  while (c > 47 && c < 58) {
    N = (N << 3) + (N << 1) + (c - 48);
    c = getchar_unlocked();
  }
  return (sign ? N : (-N));
}
inline long long int inpl() {
  long long int N = 0, sign = 1;
  register char c = getchar_unlocked();
  while (c < 48 || c > 57) {
    if (c == '-') sign = 0;
    c = getchar_unlocked();
  }
  while (c > 47 && c < 58) {
    N = (N << 3) + (N << 1) + (c - 48);
    c = getchar_unlocked();
  }
  return (sign ? N : (-N));
}
inline bool inb() {
  char c = getchar_unlocked();
  while (c < 48 || c > 57) {
    c = getchar_unlocked();
  }
  return (c == '0' ? 0 : 1);
}
inline long long int ModP(long long int b, long long int e) {
  b %= 1000000007;
  long long int r = 1;
  while (e > 0) {
    if (e & 1) r = (r * b) % 1000000007;
    b = (b * b) % 1000000007;
    e >>= 1;
  }
  return r;
}
bool pri[10] = {1, 1, 0, 0};
vector<int> prm;
inline void prime_init() {
  int i, j;
  for (i = 3; i * i < 10; i += 2) {
    if (!pri[i]) {
      for (j = i * i; j <= 10; j += 2 * i) {
        pri[j] = 1;
      }
    }
  }
}
inline void prime_asgn() {
  int i;
  prm.push_back(2);
  for (i = 3; i < 10; i += 2)
    if (!pri[i]) prm.push_back(i);
}
inline bool prime_check(long long int i) {
  if (i == 1) return 0;
  if (i < 4) return 1;
  if (i & 1) {
    if (i < 10) {
      if (!pri[i])
        return 1;
      else
        return 0;
    } else {
      int j, x;
      for (j = 1; ((x = prm[j]) * prm[j]) <= i; j++) {
        if (!(i % x)) return 0;
      }
      return 1;
    }
  } else
    return 0;
}
inline bool rngprm_check(int i) {
  if (i == 1) return 0;
  if (i < 4) return 1;
  if (i & 1) {
    if (!pri[i])
      return 1;
    else
      return 0;
  } else
    return 0;
}
inline int npf(long long int s) {
  int j, x;
  int c;
  for (c = j = 0; ((x = prm[j]) * prm[j]) <= s; j++) {
    if (!(s % x)) {
      c++;
      while (!(s % x)) {
        s /= x;
      }
    }
  }
  if (s > 1) c++;
  return (c);
}
inline int nf(long long int s) {
  if (s == 1) return 1;
  int j, x, f = 1;
  int c = 1;
  for (j = 0; ((x = prm[j]) * prm[j]) <= s; c = 1, j++) {
    if (!(s % x)) {
      while (!(s % x)) {
        s /= x;
        c++;
      }
      f = f * c;
    }
  }
  if (s > 1) {
    f = f << 1;
  }
  return (f);
}
vector<pair<int, int> > nfa;
inline void nfx(long long int s) {
  nfa.clear();
  if (s == 1) return;
  int j, x, c = 0;
  for (j = 0; ((x = prm[j]) * prm[j]) <= s; c = 0, j++) {
    if (!(s % x)) {
      while (!(s % x)) {
        s /= x;
        c++;
      }
      nfa.push_back(make_pair((x), (c)));
    }
  }
  if (s > 1) {
    nfa.push_back(make_pair((s), (1)));
  }
}
vector<long long int> factors;
inline void factr() {
  factors.clear();
  factors.push_back(1);
  long long int i, y, p, q, j;
  for (pair<int, int> x : nfa) {
    y = factors.size();
    p = x.first;
    q = x.second;
    for (j = 0; j < q; j++) {
      for (i = 0; i < y; i++) {
        factors.push_back(factors[i] * p);
      }
      p *= x.first;
    }
  }
}
long long int fc[10];
inline long long int InverseEuler(long long int n) {
  return ModP(n, 1000000007 - 2);
}
inline long long int nCr(int n, int r) {
  if (r > n) return 0;
  return (fc[n] *
          ((InverseEuler(fc[r]) * InverseEuler(fc[n - r])) % 1000000007)) %
         1000000007;
}
inline void facs() {
  fc[0] = fc[1] = 1;
  for (long long int i = 2; i < 10; i++) {
    fc[i] = (i * fc[i - 1]) % 1000000007;
  }
}
int main() {
  long long int n, p, i, x, y;
  cin >> n >> p;
  for (i = 1; i < 1000000; i++) {
    x = n - (i * p);
    if (x > 0) {
      if (__builtin_popcount(x) <= i && x >= i) {
        cout << i;
        return 0;
      }
    }
  }
  cout << -1;
  return 0;
}
