#include <bits/stdc++.h>
using namespace std;
long long add(long long a, long long b) {
  a %= 1000000007;
  b %= 1000000007;
  long long res = ((a % 1000000007) + (b % 1000000007)) % 1000000007;
  return res % 1000000007;
}
long long mul(long long a, long long b) {
  long long res = (a) * (b);
  res %= 1000000007;
  if (res < 0) res += 1000000007;
  return res;
}
const long long N = 0;
void solve() {
  long long n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 0 << "\n";
    return;
  }
  long long st = 2, en = k;
  long long ans = -1;
  bool f = 0;
  while (st <= en) {
    long long m = (st + en) / 2;
    long long no = k - m + 1;
    long long sum = no * (k + m) / 2;
    sum -= (no - 1);
    if (sum == n) {
      f = 1;
    }
    if (sum >= n) {
      ans = m;
      st = m + 1;
    } else {
      en = m - 1;
    }
  }
  if (ans == -1) {
    cout << -1 << "\n";
    return;
  }
  cout << k - ans + 1 << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
