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