//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	ll N;
	cin >> N;

	ll tmp = 2 * N + 2;

	ll are = sqrt(tmp);

	ll kotae = 0;

	if (are * (are + 1) <= tmp) chmax(kotae, are);
	if (are * (are - 1) <= tmp) chmax(kotae, are - 1);
	if ((are + 2) * (are + 1) <= tmp) chmax(kotae, are + 1);

	co(N - kotae + 1);

	Would you please return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    ll n;
    cin >> n;

    ll l, r;
    l = 0, r = 2e9;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        if (m * m + m > 2 * n + 2) r = m;
        else l = m;
    }
    cout << n - (l - 1) << endl;
    // long double s = sqrtl(8.0 * n + 9.0);
    // cout << setprecision(15) << (- 1.0 + s ) / 2.0 << endl;
    // ll m = (- 1.0 + s ) / 2.0;
    // cout << m << endl;
    // cout << n - (m - 1) << endl;
}