#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10, BASE = 3137, MOD = 1e9 + 7, inf = 1000000009;
const double PI = 3.1415926535;
const int dx[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
long long n;
int main() {
  cin >> n;
  long long sada = 1ll;
  long long foo = 1ll;
  while (true) {
    if (sada == n) {
      cout << foo << endl;
      return 0;
    }
    if (sada > n) {
      long long last = foo;
      while (true) {
        sada--;
        foo--;
        if (foo < 1) {
          foo = last - 1;
          last--;
        }
        if (sada == n) {
          cout << foo << endl;
          return 0;
        }
      }
      return 0;
    }
    foo++;
    sada += foo;
  }
  return 0;
}
