#include <bits/stdc++.h>
using namespace std;
long long cnt = 1, ans;
long long BS(long long pipes, long long n) {
  long long st = 2, ed = pipes, md;
  while (st < ed) {
    md = st + (ed - st + 1) / 2;
    ans = (((pipes * (pipes + 1)) / 2) - ((md * (md + 1)) / 2)) -
          (pipes - md - 1);
    if (ans < n) {
      ed = md - 1;
    } else {
      st = md;
    }
  }
  return ed;
}
int main() {
  long long n, pipes, sum;
  long long z = 0, cnt = 1;
  cin >> n >> pipes;
  sum = ((pipes * (pipes + 1)) / 2) - (pipes - 1);
  if (sum < n) {
    cout << "-1";
    return 0;
  } else if (sum == n) {
    cout << (pipes - 1);
    return 0;
  } else if (n < 2) {
    cout << "0";
  } else if (pipes >= n) {
    cout << "1";
    return 0;
  } else {
    long long z, ans;
    cout << pipes - BS(pipes, n);
  }
  return 0;
}
