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