#include <bits/stdc++.h>
using namespace std;
long long n, k, l, r, c;
bool check(long long x) {
  int er = 0;
  if (k - x <= 0) x = k - 1;
  long long p = (k - 1 + k - x) * x / 2 + 1;
  if (p >= n) er = 1;
  return er;
}
int main() {
  cin >> n >> k;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  l = 0;
  r = 1000000000000000000ll;
  while (r - l > 1) {
    c = (l + r) / 2;
    if (check(c))
      r = c;
    else
      l = c;
  }
  if (check(l))
    cout << l << endl;
  else if (check(l + 1))
    cout << l + 1 << endl;
  else
    cout << "-1" << endl;
  return 0;
}
