#include <bits/stdc++.h>
using namespace std;
long long n, k, tot;
inline bool check(long long x) {
  if ((k + k - x + 1) * x / 2 - x + 1 >= n)
    return true;
  else
    return false;
}
int main() {
  cin >> n >> k;
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  if ((2 + k) * (k - 1) / 2 - (k - 2) < n)
    printf("-1\n");
  else {
    long long l = 1, r = k - 1;
    while (l <= r) {
      long long mid = l + r >> 1;
      if (check(mid))
        r = mid - 1;
      else
        l = mid + 1;
    }
    cout << l << endl;
  }
  return 0;
}
