#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x, i, y;
  cin >> n;
  x = sqrt(2 * n);
  if (2 * n <= x * (x + 1)) {
    x--;
  }
  n -= (x * (x + 1)) / 2;
  cout << n;
}
