#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
#define debl(x) std::cout << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    ll n;
    cin >> n;
    ll ans = n + 1;
    ll l = 1, r = 5e9;
    while( l + 1 < r){
        ll md = (l + r) / 2;
        ll sum = md * (md + 1)/ 2;
        if(sum == ans){
            l = md;
            cout << ans - l << endl;
            return;
        }else if ( sum > ans){
            r = md - 1;
        }else{
            l = md;
        }
    }
    if ( ans >= r * ( r + 1) / 2){
        cout << ans - r << endl;
    }else{
        cout << ans - l << endl; 
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include <utility>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,l,n) for(ll i=(l);i<(n);i++)
#define per(i,n) for(ll i=(n);i>0;i--)
#define pf(n) printf("%d\n",n)
#define pf_(a) printf("%d  ",a);
#define all(v) begin(v),end(v)
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);
const ll mod = 1000000007;

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n) {
		rep(i, n) par[i] = i;
	}
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	ll n;
	cin >> n;
	ll a = n + 1;
	ll i = 1;
	ll cnt = 0;
	while (a >= i) {
		a -= i;
		i++;
		cnt++;
	}
	cout << n - cnt +1 << endl;

	return 0;
}