#include <bits/stdc++.h>
using namespace std;
long long n, k, s;
long long SUM(long long m) { return (m * (m + 1)) / 2; }
long long sum(long long s, long long n) {
  if (s <= 1)
    return SUM(n);
  else
    return SUM(n) - SUM(s - 1);
}
long long BS(long long k, long long n) {
  long long st = 1, en = k;
  while (st < en) {
    long long mid = (st + en) / 2;
    if (sum(mid, k) == n)
      return k - mid + 1;
    else if (sum(mid, k) > n)
      st = mid + 1;
    else
      en = mid;
  }
  return k - st + 2;
}
int main(int argc, char** argv) {
  cin >> n >> k;
  if (n == 1)
    printf("0");
  else if (n == k)
    printf("1");
  else {
    k--;
    n--;
    if (SUM(k) < n)
      printf("-1");
    else
      printf("%d", BS(k, n));
  }
  return 0;
}
