#pragma warning (disable:4996)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define ll long long

#define REP(i, n) for(ll i = 0; i < n; i++)
#define SET(a) ll a = 0; (void)scanf("%lld", &a);

/*
ll cutLog(ll);
ll sum(ll);
*/

ll cutLogNew(ll);

int main() {
	SET(n);
	if (n == 1 || n == 2)printf("1");
	else printf("%lld", n - cutLogNew(n) + 1);
	return 0;
}

/*
ll cutLog(ll n) {
	ll ans;
	REP(i, n + 1) {
		if (sum(i + 1) > n + 1) {
			ans = i;
			break;
		}
	}
	return ans;
}

ll sum(ll n) {
	ll sum = 0;
	REP(i, n) {
		sum += (i + 1);
	}
	return sum;
}
*/

ll cutLogNew(ll n) {
	ll ans = 0;
	ll m = n + 1;
	REP(i, n) {
		m -= (i + 1);
		if (m < 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT  = std::numeric_limits<int>::max(); // 2147483647 = 2^31-1
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL   = std::numeric_limits<long long>::max();
static const int  INF      = (1 << 28);

#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ull sumN(const ull N) {
    ull ans;
    if (N % 2 == 0) {
        ans = N /2;
        ans *= (N+1);
    }
    else {
        ans = (N+1) /2;
        ans *= N;
    }
    return ans;
}

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    ull N; cin >> N;

    ull ok = 0;
    ull ng = 10e10;

    while ((ng - ok) > 1) {
        ull mid = (ok+ng) / 2;
        ull sum = sumN(mid);
        if (sum > (N + 1) ) {
            ng = mid;
        }
        else
        {
            ok = mid;
        }
    }
    cout << N + 1 - ok << endl;

}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    double tmp;
    cin >> tmp;

    return 0;
}
