#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long sum = n * (n + 1) / 2;
  while (k > sum) {
    k -= sum;
  }
  long long x = (-1 + sqrt(1 + (8 * k))) / 2;
  long long y = (x * (x + 1)) / 2;
  cout << (k - y) << endl;
  return 0;
}
