#include <bits/stdc++.h>
using namespace std;
int oo = 1 << 25;
__inline long long cum(long long c) { return (c * (c + 1)) / 2; }
int main() {
  long long n, k;
  while (cin >> n >> k) {
    long long sum = 1;
    int c = 0;
    long long b = 1, e = k, res = -1;
    while (b <= e) {
      long long mid = (b + e) / 2;
      if (cum(k) - cum(mid) - (k - mid - 1) < n)
        e = mid - 1;
      else
        b = mid + 1, res = mid;
    }
    if (res > 0)
      cout << k - res << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
