#include <bits/stdc++.h>
long long sum(int a, int b) {
  if (a == 2)
    return 2;
  else
    return (a + b) * (a - b + 1) / 2;
}
int great(int n, int t) {
  t -= 2;
  int s = t;
  if (n > sum(t, t / 2)) return t / 2;
  while (n < sum(s, s - t) && t > 0) {
    t /= 2;
  }
  return s - t;
}
int main() {
  long long n;
  int k, count = 1;
  scanf("%I64d%d", &n, &k);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  n -= k;
  int i = k - 1;
  for (; i >= 2; i--) {
    if (n <= 0) break;
    n -= (i - 1);
    count++;
  }
  if (n > 0)
    printf("-1\n");
  else
    printf("%d\n", count);
}
