#include <bits/stdc++.h>
using namespace std;
int main(){
int k, day = 1, count = 0, coin = 0;
cin >> k;
while (count < k)
{
count += day;
day++;
}
for (int i = 1; i <= day - 1; i++)
coin += pow(i, 2);
cout << coin - ((count - k) * (day - 1)) <<endl;
}