#include <bits/stdc++.h>
using namespace std;
const long long inf = LONG_MAX;
const long long arr = 1000000;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first < b.first;
}
int main(void) {
  long long n;
  cin >> n;
  long long sum = 0;
  for (long long i = 1; i <= LONG_MAX; i++) {
    sum += i;
    if (sum >= n) {
      sum -= i;
      n -= sum;
      break;
    }
  }
  cout << n << '\n';
  return 0;
}
