#include <bits/stdc++.h>
using namespace std;
int main() {
  int NWarm, NChip;
  cin >> NWarm >> NChip;
  int temp = NWarm * (NWarm + 1) / 2;
  int ans = NChip % temp;
  int i;
  for (i = 1; i <= temp; i++) {
    ans = ans - i;
    if (ans < 0) break;
  }
  int ans1 = ans + i;
  cout << ans1 << endl;
}
