#include <bits/stdc++.h>
using namespace std;
long long splitters(long long n, long long k) {
  if (n == 1) return 0;
  if (n <= k) return 1;
  --k;
  long long l = 1;
  long long r = k;
  long long rhs = 2 * n - k * k - k - 2;
  while (l <= r) {
    long long mid = (l + r) / 2;
    long long lhs = mid - mid * mid;
    if (lhs >= rhs) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  if (r < 1) return -1;
  return k - r + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long(n);
  cin >> n;
  long long(k);
  cin >> k;
  cout << (splitters(n, k)) << '\n';
  return 0;
}
