#include <bits/stdc++.h>
using namespace std;
long long sum(long long n) { return (n * (n + 1)) / 2; }
long long sum(long long a, long long b) {
  if (sum(a) <= 1)
    return sum(b);
  else
    return (sum(b) - sum(a - 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  --k, --n;
  if (n == 0)
    cout << 0;
  else if (n <= k)
    cout << 1;
  else if (sum(k) < n)
    cout << -1;
  else {
    long long start = 1, end = k, mid;
    bool flag = true;
    while (start < end) {
      mid = start + (end - start) / 2;
      long long s = sum(mid, k);
      if (s == n) {
        flag = false;
        cout << k - mid + 1;
      }
      if (s > n) {
        start = mid + 1;
      } else
        end = mid;
    }
    if (flag) cout << k - start + 2;
  }
}
