#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, x = 1, sum = 0;
  cin >> n;
  while (sum < n) {
    sum += x;
    x++;
  }
  cout << x - (sum % n) - 1;
  return 0;
}
