#include <bits/stdc++.h>
int mod(int a, int b) {
  int r = a % b;
  return r < 0 ? r + b : r;
}
int main(int argn, char** args) {
  long long n;
  long long i = 1;
  long long s = 1;
  long long diff;
  scanf("%lld", &n);
  diff = n - s;
  while (diff > 0) {
    i++;
    s = i * (i + 1) / 2;
    diff = n - s;
  }
  if (diff < 0) {
    diff = mod(diff, i);
    printf("%lld\n", diff);
  } else if (diff == 0) {
    printf("%lld\n", i);
  }
  return 0;
}
