/*
Bismillah Hir Rahmanir Rahim
*MAY ALLAH HELP ME*
*/
///Containers Start..
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <ctime>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <math.h>
#include <algorithm>
///Container End.
/// **** So be patient. Indeed, the promise of ALLAH is truth - QURAN - 30:60 ****
///Macro Start..
#define PI acos(-1.0)
#define LL long long
#define pii pair <int, int>
#define ppi pair <pii, int>
#define ff first
#define ss second
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define nn '\n'
#define all(c) (c).begin(), (c).end()
///Macro End.
using namespace std;
int main()
{
/// I May Not Be Able To Solve Today's Problems, But I Will Learn, And Obiviously I Can Solve Every Problems One Day :)
long long int n, sum, total, x;
cin >> n;
x = floor( ( sqrt( 8 * n + 1 ) - 1 ) / 2 );
//cout << x << endl;
total = n - (x * ( x + 1)) / 2;
//cout << total << endl;
if( total == 0 && x > 0 )
{
cout << x << endl;
}
else if( total == x )
{
cout << x << endl;
}
else if( x > total )
{
cout << total << endl;
}
return 0;
}
LyoKICAgIEJpc21pbGxhaCBIaXIgUmFobWFuaXIgUmFoaW0KCiAgICAqTUFZIEFMTEFIIEhFTFAgTUUqCiovCgovLy9Db250YWluZXJzIFN0YXJ0Li4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y2N0eXBlPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3RpbWU+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzdGFjaz4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8dXRpbGl0eT4KI2luY2x1ZGUgPG1hdGguaD4KI2luY2x1ZGUgP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