#include <bits/stdc++.h>
int f(int x, int y) {
  int n = (-1 + sqrt((1 + 8 * y))) / 2;
  if (n >= x)
    return f(x, (y - ((x * (x + 1)) / 2)));
  else
    return y - ((n * (n + 1)) / 2);
}
int main() {
  int x, y, n;
  scanf("%d %d", &x, &y);
  printf("%d\n", f(x, y));
  return 0;
}
