#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int r = k, l = 0, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if ((mid * (mid + 1) / 2) >= k) {
      if ((mid * (mid - 1)) / 2 >= k) {
        r = mid - 1;
      } else
        break;
    } else {
      l = mid + 1;
    }
  }
  long long int c = mid, eat = 0;
  if (c == n) {
    cout << 0 << endl;
  } else {
    long long int avl = abs(((c * (c + 1)) / 2) - k);
    n -= c;
    if (n <= avl) {
      cout << n << endl;
    } else {
      c++;
      while (n > 0) {
        if (c > n) {
          eat += n;
          n = 0;
        } else {
          eat += c;
          n -= c;
          c++;
          n--;
        }
      }
      cout << eat << endl;
    }
  }
  return 0;
}
