#include <bits/stdc++.h>
using namespace std;
unsigned long long k;
inline unsigned long long Q(unsigned long long x) {
  if (x % 2 == 0) {
    return x / 2 * (k + k - x + 1);
  } else {
    return (k + k - x + 1) / 2 * x;
  }
}
int main() {
  unsigned long long n, l, r, mid;
  cin >> n >> k;
  n--;
  k--;
  if (n == 0) {
    cout << "0";
    return 0;
  }
  if (Q(k) < n) {
    cout << "-1";
    return 0;
  }
  l = 1;
  r = k;
  while (l <= r) {
    mid = (l + r) / 2;
    if (Q(mid) > n) {
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  while (Q(r) < n) {
    r++;
  }
  while (Q(r - 1) >= n && Q(r) >= n) {
    r--;
  }
  cout << r;
}
