#include <bits/stdc++.h>
using namespace std;
long long n, k;
bool check(long long mid) {
  long long sum = (mid + k - 1) * (k - mid) / 2;
  return (sum >= n - 1);
}
int main() {
  scanf("%I64d%I64d", &n, &k);
  if (n == 1) {
    printf("0");
    return 0;
  }
  long long l = 1, r = k - 1, mid;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  if ((l + k - 1) * (k - l) / 2 >= n - 1)
    printf("%I64d", k - l);
  else
    printf("-1");
}
