#include <bits/stdc++.h>
using namespace std;
long long n, k;
bool check(long long mid) {
  long long now = k * mid - (mid - 1) * mid / 2 - mid + 1;
  if (now >= n) return true;
  return false;
}
int main() {
  cin >> n >> k;
  long long left = -1, right = k;
  if (k * (k - 1) - (k - 2) * (k - 1) / 2 - k + 2 < n) {
    cout << -1;
    return 0;
  }
  while (right - left > 1) {
    long long mid = right + left >> 1;
    if (check(mid)) {
      right = mid;
    } else {
      left = mid;
    }
  }
  cout << right;
}
