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