#include <iostream>

using namespace std;

int main()
{
    unsigned long long int n;
    cin>>n;
    unsigned long long i=1;
    while(i*(i+1)/2<=n+1)
          i++;
    cout<<n-i+2<<endl;
    return 0;
}


//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<ctime>
//#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

//ここに適切な判断条件を書く
bool isOK(ll index,ll n) {
  if((long double)((index+1) <= 2.0*(long double)(n+1)/(long double)(index)) and ((index*(index+1))/2 <= n+1)) return true;
  return false;
}

//臨機応変に引数を書き換える
int binary_search(ll n) {
    ll ok = 0;
    ll ng = min(n,ll(2000000002));


    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid,n)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){

   
  
  ll n; cin >> n;
  
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  if(n == 2){
    cout << 1 << endl;
    return 0;
  }
  cout << n-binary_search(n)+1 << endl;


  /*cout << ( double(1000000002+1) <= 2.0*double(109109109109109109
+1)/double(1000000002)
 ? "Yes" : "No") << endl; 
  */
  
}