#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, k;
  cin >> n >> k;
  int i;
  long long int x = k - 1;
  x = (x * (x + 1)) / 2 + 1;
  if (n == 1) {
    cout << "0";
    return 0;
  }
  if (n <= k)
    cout << "1" << '\n';
  else if (n > x)
    cout << -1;
  else if (n == x)
    cout << k - 1;
  else if (n == x - 1)
    cout << k - 2;
  else {
    n--;
    long long int c = 0;
    k--;
    while (n > 0) {
      long long int l = 0, r = k, m, ans = -1;
      while (l <= r) {
        m = (l + r) / 2;
        if (((k * (k + 1)) / 2) - ((m * (m + 1)) / 2) > n)
          l = m + 1;
        else
          r = m - 1, ans = m;
      }
      n -= (k * (k + 1)) / 2 - (ans * (ans + 1)) / 2;
      c += k - ans;
      k = min(n, ans - 1);
    }
    cout << c;
  }
  return 0;
}
