#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, chips;
  cin >> n >> chips;
  n++;
  bool flag = true;
  long long int k = 0;
  while (flag && chips > 0) {
    if (k % n <= chips)
      chips -= k % n;
    else
      flag = false;
    k++;
  }
  cout << chips;
  return 0;
}
