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