#include <bits/stdc++.h>
long long int i, j, k, m, n, a, b;
int main() {
  while (scanf("%I64d %I64d", &n, &k) == 2) {
    if ((2 + k) * (k - 1) / 2 - (k - 2) < n) {
      printf("-1\n");
      continue;
    }
    if (n == 1) {
      printf("0\n");
      continue;
    }
    a = 2;
    b = k;
    while (a != b - 1) {
      m = (a + b) / 2;
      if ((m + k) * (k - m + 1) / 2 - (k - m) < n)
        b = m;
      else
        a = m;
    }
    if ((b + k) * (k - b + 1) / 2 - (k - b) >= n)
      printf("%I64d\n", k - a);
    else
      printf("%I64d\n", k - a + 1);
  }
  return 0;
}
