#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long k;
  cin >> n >> k;
  if ((k * (k + 1) / 2) - k + 1 < n) {
    cout << "-1" << endl;
  } else {
    long long res = 0;
    long long num = 1;
    int i = k - 1;
    while (num < n) {
      num = num + i;
      res++;
      i--;
    }
    cout << res << endl;
  }
}
