#include <bits/stdc++.h>
using namespace std;
bool equiv(string a, string b) {
  if (a == b) return true;
  int L = a.length();
  if (L % 2 != 0) return false;
  string a1 = a.substr(0, L / 2);
  string a2 = a.substr(L / 2, L / 2);
  string b1 = b.substr(0, L / 2);
  string b2 = b.substr(L / 2, L / 2);
  bool check = equiv(a1, b1) && equiv(a2, b2);
  if (check)
    return true;
  else
    check = equiv(a1, b2) && equiv(a2, b1);
  return check;
}
bool is_prime(int n) {
  int count_primes = 0;
  for (int i = 1; i < n + 1; i++) {
    if (n % i == 0) count_primes++;
  }
  if (count_primes == 2) return true;
  return false;
}
bool valid_or_not(int num1, int num2, int num3, int num4, int r1, int r2,
                  int c1, int c2, int d1, int d2) {
  bool validity = ((num1 + num2) == r1) && ((num1 + num3) == c1) &&
                  ((num1 + num4) == d1) && ((num2 + num4) == c2) &&
                  ((num2 + num3) == d2) && ((num3 + num4) == r2);
  return validity;
}
long long sum(long long n) { return (n * (n + 1) / 2); }
long long sum_interval(long long st, long long en) {
  if (st <= 1) return sum(en);
  return (sum(en) - sum(st - 1));
}
long long find_min_possible(long long n, long long k) {
  long long s = 1, e = k;
  while (s < e) {
    long long mid = (s + e) / 2;
    long long su = sum_interval(mid, k);
    if (su == n)
      return (k - mid + 1);
    else if (su > n)
      s = mid + 1;
    else
      e = mid;
  }
  return k - s + 2;
}
int main() {
  long long n, k;
  cin >> n >> k;
  if (n == 1)
    printf("%d\n", 0);
  else if (n <= k)
    printf("%d\n", 1);
  else {
    k--;
    n--;
    if (sum(k) < n)
      printf("%d\n", -1);
    else
      printf("%I64d\n", find_min_possible(n, k));
  }
  return 0;
}
