#include <bits/stdc++.h>
int main(void) {
  int walruses, chips;
  int flag = 1, current = 1;
  scanf("%d %d", &walruses, &chips);
  walruses++;
  while (flag) {
    if (chips >= current) {
      chips -= current;
      current++;
      if (current == walruses) current = 1;
    } else
      flag = 0;
  }
  printf("%d\n", chips);
  return 0;
}
