//#include <atcoder/all>
#include <bits/stdc++.h>
#include <cassert>
#include <numeric>
using namespace std;
//using namespace atcoder;
typedef  long long LONG;
const int MOD = 1000000007;



int gcd(int x, int y) {
	if (x % y == 0) {
		return y;
	}
	else {
		return gcd(y, x % y);
		//x%y==0でないときはユーグリットの互除法を使って再帰的に関数を呼び出す。
	}
}
LONG pow2(long long x, long long n) {
	long long ret = 1;
	while (n > 0) {
		if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
		x = x * x % MOD;
		n >>= 1;  // n を1bit 左にずらす
	}
	return (int)ret;
}
void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}
LONG t(LONG N, LONG i) {
	return N - abs(i);
}
int count(vector<int>&a, int s) {
	int result = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == s) {
			result++;
		}
	}
	return result;
}

LONG kaizyo(int N) {
	LONG result = 1;
	LONG mod = 998244353;

	for (LONG i = 2; i <= N; i++) {
		result *= i;
		result = result % mod;
	}
	return result;
}
class Point {
public:
	int x;
	int y;
};
LONG stock[3500][3500];
LONG test(int N, int task) {
	LONG mod = 998244353;
	if (N < task)return 0;
	if (N < 0)return 0;
	if (task == 0) {
		if (N == 0) {
			return 1;
		}
		else {
			return 0;
		}

	}


	if (stock[N][task] > 0)return stock[N][task];
	stock[N][task] = (test(N - 1, task - 1) + test(N, task * 2)) % mod;

	return stock[N][task] % mod;
}
class DP {
public:
	DP() {

	}
	DP(int a, int b) {
		other = a;
		path = b;

	}
	int other;
	int path;
};

void dp(vector<vector<DP>>& list, vector<int> &able, int pos, int limit) {
	for (int i = 0; i < list[pos].size(); i++) {
		if (list[pos][i].path <= limit) {
			if (able[list[pos][i].other] == 0) {
				able[list[pos][i].other] = 1;
				dp(list, able, list[pos][i].other, limit);
			}
		}
	}
}
LONG max(deque<LONG>q) {
	LONG r = -1;
	for (int i = 0; i < q.size(); i++) {
		if (r < q[i]) {
			r = q[i];
		}
	}
	return r;
}
LONG min(deque<LONG>q) {
	LONG r = LLONG_MAX;
	for (int i = 0; i < q.size(); i++) {
		if (r > q[i]) {
			r = q[i];
		}
	}
	return r;
}
int main() {
	LONG n, n2, n3;
	cin >> n;
	int a = int((-0.5 + sqrt(0.25 + 2 * (n + 1))));
	for (LONG i = a;; i++) {
		if (i*(i + 1) > 2 * (n+1)) {
			cout << n - i + 2 << endl;
			return 0;

		}
	}
	return 0;



	return 0;

}
#include<bits/stdc++.h>
using ull = unsigned long long;
using namespace std;

ull solve1(ull n) {
  ull valid = 0;
  ull invalid = INT32_MAX;
  while (invalid - valid > 1) {
    ull mid = (valid + invalid) / 2;
    if (mid * (mid + 1) / 2 <= n + 1) valid = mid;
    else invalid = mid;
  }
  return n + 1 - valid;
}

ull solve2(ull n) {
  ull valid = 0;
  ull width = INT32_MAX;
  while (width > 1) {
    ull mid = valid + width / 2;
    if (mid * (mid + 1) / 2 <= n + 1) valid = mid;
    width -= width / 2;
  }
  return n + 1 - valid;
}

const int CNT = 10000000;
int main() {
  ull n;
  cin >> n;
  ull res = 0;
  for (int i = 0; i < CNT; i++) {
    res += solve2(n);
  }
  cerr << res << endl;
  cout << solve2(n) << endl;
}
