#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  ll n, k;
  cin >> n >> k;
  if (n > k * (k - 1) / 2 + 1) {
    cout << "-1\n";
  } else {
    ll ans = 1, cnt = 0;
    while (ans < n) {
      ans += k - 1;
      k--;
      cnt++;
    }
    cout << cnt << "\n";
  }
}
