#include <bits/stdc++.h>
long long n, k;
long long sum(long long n) { return (n * (n + 1)) / 2; }
long long sum(long long a, long long b) {
  if (a <= 1) return sum(b);
  return sum(b) - sum(a - 1);
}
long long search(long long n, long long k) {
  long long st = 1, en = k;
  while (st < en) {
    long long mid = (st + en) / 2;
    if (sum(mid, k) == n) return k - mid + 1;
    if (sum(mid, k) > n)
      st = mid + 1;
    else
      en = mid;
  }
  return k - st + 2;
}
void solve() {
  scanf("%I64d%I64d", &n, &k);
  if (n == 1)
    printf("%i\n", 0);
  else if (n <= k)
    puts("1");
  else {
    --n;
    --k;
    if (sum(k) < n)
      puts("-1");
    else
      printf("%I64d\n", search(n, k));
  }
}
int main() { solve(); }
