#include <bits/stdc++.h>
using namespace std;
long long sum(long long a) { return a * (a + 1) / 2; }
int main() {
  long long n, k;
  cin >> n >> k;
  if (1 + sum(k - 1) < n) {
    cout << -1 << endl;
    return 0;
  }
  int a = 0;
  int b = k - 1;
  while (a < b) {
    int c = (a + b) / 2;
    if (1 + sum(k - 1) - sum(k - 1 - c) < n)
      a = c + 1;
    else
      b = c;
  }
  cout << b << endl;
  return 0;
}
