#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, res = 0, temp = 0;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    n = n - i;
    res = n;
    if (n == 0) {
      res = i;
      break;
    } else if (n < 0) {
      res = i - res;
      break;
    }
  }
  cout << res << endl;
  return 0;
}
