#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11, mod = 1e9 + 7;
const int INF1 = 2e9;
const long long INF2 = 2e18;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const double EPS = 1e-9;
const double PI = acos(-1.0);
long long n, m = 1;
int ans, k;
int main() {
  if (fopen("queue"
            ".in",
            "r"))
    freopen(
        "queue"
        ".in",
        "r", stdin),
        freopen(
            "queue"
            ".out",
            "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  while (ans < k && m < n) ++ans, m += k - ans;
  if (m < n) return !(cout << -1);
  cout << ans;
  return 0;
}
