#include <bits/stdc++.h>
using namespace std;
const int oo = 1000 * 1000 * 1000;
long long n, k, ans, t;
long long binary_search(long long st, long long ed) {
  if (ed == st) return st;
  if (ed == st + 1) {
    long long mid = ed;
    long long x = (long long)mid * (mid - 1) / 2;
    long long tt = k - mid + 1 - 1;
    if (t - x - tt >= n) return ed;
    return st;
  }
  long long mid = (st + ed) / 2;
  long long x = (long long)mid * (mid - 1) / 2;
  long long tt = k - mid + 1 - 1;
  if (t - x - tt >= n) return binary_search(mid, ed);
  return binary_search(st, mid - 1);
}
int main() {
  cin >> n >> k;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  t = (long long)k * (k + 1) / 2;
  if (t - 1 - (k - 2) < n) {
    cout << -1 << endl;
    return 0;
  }
  ans = binary_search(0, k);
  cout << k - ans + 1 << endl;
  return 0;
}
