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