#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-8;
const long long INF = (long long)(1e18);
const long long mod = (int)(1e+9 + 7);
const int N = (int)(1e5);
int days_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long n, k;
inline long long cnt(long long x) { return (x - 1) * x / 2 + 1; }
long long bs() {
  long long l = 1;
  long long r = k;
  while (l <= r) {
    long long me =
        ((((l + r)) / ((2)) - (((l + r)) < 0 && ((l + r)) % ((2)) != 0)) +
         ((l + r) % (2) > 0));
    if (cnt(k) - cnt(me) + 1 >= n)
      l = me + 1;
    else
      r = me - 1;
  }
  return k - r;
}
int main() {
  cin >> n >> k;
  if (cnt(k) < n) return cout << -1, 0;
  ;
  cout << bs();
  return 0;
}
