#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.141592653589793238462643383;
const double PI = 3.141592653589793;
template <class T>
using max_pq = priority_queue<T>;
template <class T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;
vector<bool> primeSieve(int n) {
  std::vector<bool> p(n + 1, false);
  p[0] = p[1] = 0;
  p[2] = 1;
  for (int i = 3; i <= n; i += 2) {
    p[i] = 1;
  }
  for (int i = 3; i <= sqrt(n); i += 2) {
    if (p[i]) {
      for (int j = i * i; j <= n; j += 2 * i) {
        p[j] = 0;
      }
    }
  }
  return p;
}
long long int power(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int smallpower = power(x, y / 2, m);
  smallpower = smallpower % m;
  smallpower = (smallpower * smallpower) % m;
  if (y & 1)
    return (x * smallpower) % m;
  else
    return (smallpower % m);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int c = 1;
    int num = 1;
    int eat = 0;
    for (int i = 1; i < n; i++) {
      ++num;
      while (c > k || c + num > k) {
        --c;
        ++i;
        ++eat;
      }
      c += num;
    }
    cout << eat << endl;
  }
  return 0;
}
