/*And I thought my jokes were bad*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("Viva la vida");
#define CHECK(x) cout << (#x) << " is " << (x) << endl;
#define nl puts("");
#define mp make_pair
#define IN(x) scanf("%d",&x);
#define INL(x) scanf("%lld",&x);
#define OUT(x) printf("%d",x);
#define OUTL(x) printf("%lld",x);
#define MAX 200005
#define MOD 1000000009
#define INF (1 << 31)
#define CASE(x,y) printf("Case %d: %d\n",++x,y);
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define PI acos(-1.0)
#define EPS 1e-19
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int ll
/*
	When I get older
	I will be stronger
	they'll call me freedom
	just like a waving flag
*/

void solve()
{
	int j,l,r,m,a,b,c,d,x,y,z,t,p;
	unsigned int i,n,k;
	cin>>n;
	x=n+1;
	i=1;

	for(j=30;j>=0;j--)
	{
		k=i+(1LL<<j);

		if(k*(k+1)/2<=x)
			i=k;
	}
	cout<<(n-i+1)<<endl;
}
int32_t main()
{
	FASTIO
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;
 
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;


int main() {
    ll n; cin >> n;
    ll ng = 2ll * (ll)1e9;
    ll ok = 0;
    while(llabs(ok - ng) > 1ll) {
        ll x = (ok+ng) / 2;
        if(x * (x+1) / 2 <= (n+1)) ok = x;
        else ng = x;
    }
    cout << (n+1) - ok << endl;
    return 0;
}