#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, st, dr, mid, sum, i, last, lasti;
  cin >> n;
  for (i = 1; (i * (i + 1)) / 2 <= n; ++i) {
    last = (i * (i + 1)) / 2;
    lasti = i;
  }
  if (n % last == 0)
    cout << lasti;
  else
    cout << n % last;
  return 0;
}
