#include <bits/stdc++.h>
using namespace std;
const int size = 504;
const long long inf = 1e18;
int main() {
  long long n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  long long l = 1, r = k - 1;
  while (l < r) {
    long long mid = (l + r) >> 1;
    long long res = k * mid - (mid + 1) * mid / 2 + 1;
    if (res >= n)
      r = mid;
    else
      l = mid + 1;
  }
  long long res = k * l - (l + 1) * l / 2 + 1;
  if (res >= n)
    cout << l;
  else
    cout << -1;
  return 0;
}
