#include <bits/stdc++.h>
using namespace std;
const long long N = 1e+6 + 5;
long long big = 1e+18 + 3;
long long mod = 1e+9 + 7;
long long n, k;
long long sum(long long last) {
  long long value = k * (k + 1);
  value -= (k - last) * (k - last + 1);
  value /= 2;
  return (value - last);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long remove = 0;
  long long low = 1;
  long long high = k - 1;
  long long diff = n - 1;
  long long take = 0;
  if (diff)
    while (low <= high) {
      long long mid = (low + high) / 2;
      if (sum(mid) <= diff) {
        take = mid;
        low = mid + 1;
      } else
        high = mid - 1;
    }
  diff -= sum(take);
  if (take == k - 1 && diff)
    cout << -1 << "\n";
  else if (diff)
    cout << ++take << "\n";
  else
    cout << take << "\n";
}
