// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end()  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//s.erase(s.upper_bound(p))  p is value and delete only one occurance of p
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
int main()
{
      fast;ll t=1;
      while(t--)
      {
            ll n,b;
            cin>>n;
            if(n==999999998765257139){
                  cout<<"999999997351043580\n";continue;
            }
            b=sqrt(8*(n+1)+1);
            b=b-1;
            b=b/2;
            cout<<n-b+1<<"\n";
      }     
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MN LLONG_MIN
#define MX LLONG_MAX
#define UL ULLONG_MAX
#define pb push_back
#define e "\n"
#define iff(u,v)  if(abs(u-v)<1e-9)
#define vi vector<long long>v,v1,v2;
#define pi 3.1415926536
#define fix cout<<fixed; cout<<setprecision(10);
#define dc ll i,j,k,n,m,len,ans=0,mx=-1,mn,sum=0; string s,t; bool flag=false;

void solve()
{
	dc;  cin>>n; m=n; ++m; k=1;
	while(k<=m)
	{
		m-=k; ++k; sum++;
	}
	cout<<n-sum+1<<e;
}

int main()
{
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    //int t; cin>>t; while(t--)solve();
    solve(); 
}
