#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  while (cin >> b >> a) {
    while (0 < a) {
      for (c = 0; c <= b && a > 0; c++) a = a - c;
    }
    if (a != 0) a = a + (c - 1);
    cout << a << endl;
  }
  return 0;
}
