#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, t = 0;
  cin >> n >> m;
  int x[n];
  while (m > 0) {
    for (int i = 1; i <= n && m > 0; i++) {
      m -= i;
      t = i;
    }
  }
  if (m != 0) m += t;
  cout << m << endl;
}
