#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, k;
  cin >> k >> s;
  while (s >= 1) {
    for (int i = 1; i <= k; i++) {
      if (s >= i) {
        s = s - i;
      } else {
        cout << s << endl;
        return 0;
      }
    }
  }
  cout << s << endl;
}
