#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, k;
  cin >> n >> k;
  long long l = 0, h = n;
  long long ans = -1;
  while (l <= h) {
    long long mid = l + (h - l) / 2;
    long long max_candy = (n - mid) * (n - mid + 1) / 2;
    long long left_candy = max_candy - mid;
    if (left_candy == k) {
      ans = mid;
      break;
    } else if (left_candy < k)
      h = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans << "\n";
  return 0;
}
