#include <bits/stdc++.h>
int main() {
  int n_chip, n, i, j, k, restc, f = 0;
  scanf("%d", &n);
  scanf("%d", &n_chip);
  k = n_chip;
  for (i = 0; i <= k; i++) {
    for (j = 1; j <= n; j++) {
      if (n_chip >= j) {
        n_chip = n_chip - j;
      } else {
        restc = n_chip;
        f = 1;
        break;
      }
    }
    if (f == 1) break;
  }
  printf("%d", restc);
}
