#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
unordered_set<long long> s;
long long pipes(long long k) {
  while (s.find(k) != s.end()) {
    k--;
  }
  return k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  long long p = 1;
  long long count = 0;
  k = k - 1;
  long long ksum = ((k) * (k + 1)) / 2;
  long long psum = 0;
  if (ksum < n - 1) {
    cout << -1;
    return 0;
  }
  long long l = 0;
  long long r = k;
  long long mid;
  if (k >= n) {
    cout << 1;
    return 0;
  }
  while (l < r) {
    mid = (l + r) % 2 ? (l + r) / 2 + 1 : (l + r) / 2;
    psum = ((mid) * (mid + 1)) / 2;
    if (l == r) break;
    if (ksum - psum >= n - 1) {
      l = mid;
    } else
      r = mid - 1;
  }
  cout << k - l << "\n";
  return 0;
}
