#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()
#define INF numeric_limits<ll>::max()
 
int main(){
	ll n,i,ans;
	cin >>n;
	n++;
	for(i=(ll)sqrt(2*n);i*(i+1)>2*n;i--){
	}
	
	cout << n-i << endl;
	return 0;

}

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{   ios_base::sync_with_stdio(false); cin.tie(0);
 
    long long n, min, max;
    cin>>n;
    min = 0;
    max = n+1;
    while(max > min){
        min++;
        max-=min;
    }
    cout<<n-min+1<<endl;
}