#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
int main() {
  srand(rdtsc());
  long long n;
  long long k;
  while (scanf("%lld"
               "%lld",
               &n, &k) >= 1) {
    --k;
    if (k * (k + 1) / 2 + 1 < n)
      printf("-1\n");
    else {
      --n;
      long long l = 0, r = k + 1;
      while (l + 1 < r) {
        long long m = l + (r - l) / 2;
        if (k * (k + 1) / 2 - m * (m - 1) / 2 <= n)
          r = m;
        else
          l = m;
      }
      n -= k * (k + 1) / 2 - r * (r - 1) / 2;
      printf(
          "%lld"
          "\n",
          !!n + (k + 1 - r));
    }
  }
  return 0;
}
