#include <bits/stdc++.h>
long long n, i, step = 1 << 25;
int main() {
  for (std::cin >> n; step; step /= 2)
    for (; ((i + step) * (i + step + 1) / 2) < n; i += step)
      ;
  std::cout << n - ((i) * (i + 1) / 2);
}
