#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int INFINITE = 0x3f3f3f3f;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T lowbit(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  scanf("%lld%lld", &n, &k);
  --n, --k;
  if (k * (k + 1) / 2 < n)
    printf("-1\n");
  else {
    long long res = 0ll;
    while (n) {
      checkmin(k, n);
      long long lo = 1ll, hi = k;
      while (lo < hi) {
        long long mid = (lo + hi) / 2;
        if (k * (k + 1) / 2 - mid * (mid - 1) / 2 > n)
          lo = mid + 1ll;
        else
          hi = mid;
      }
      res += k - lo + 1;
      n -= k * (k + 1) / 2 - (lo - 1) * lo / 2;
    }
    printf("%I64d\n", res);
  }
  return 0;
}
