#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int bit(int i,int n,int u)
{
do
{
i=i+1;
}while(pow(i,u)<n);
return i;
}
int main() {
double n,result,p;//переменные для результата и количество кубиков,на всякий случай большой размерности
long long int i=0,g=0;//объявляем переенные для разрядностей
cin>>n;
i=bit(i,n,3);//находим разрядность куба
if ((i*i*(i-1))>=n)//проверка третьего этапа
{
if (((i-1)*(i-1)*i)>=n)//проверка первого этапа и если правда,то решение первого этапа
{
double o=i-1;
result=8*o+4+5*o*(o-1)*2+3*(o-1)*2+3*o*(o-1)*(o-1)+2*(o-1)*(o-1);//результату присваем прошылй куб
p=n-o*o*o;//количество оставшихся кубов
g=bit(g,p,2);//разрядность плоскости
if (g==1)//проверка разрядности на 1
result+=8;//увеличение результата на 8 при разрядности 1
else
result+=8+(g-2)*2*5+3*((g-1)*(g-1)-1-(g-2)*2);//увеличение результата по формуле
for (long int i = 1;(g-1)*(g-1)+i <= p;i++)
{
if ((i == 1 || i == g) && g != 1)
{
result+=5;
}
else if (g != 1)
{
result+=3;
}
}
}
else//решение второго этапа
{
double o=i-1;
result=8*o+4+5*o*(o-1)*2+3*(o-1)*2+3*o*(o-1)*(o-1)+2*(o-1)*(o-1)+o*o*3+5+2*2*(o-1);//результат по формуле+ещё достроеная на первом этапе стенка
p=n-o*o*(o+1);
g=bit(g,p,2);
if (g==1)
result+=8;
else
result+=8+(g-2)*2*5+3*((g-1)*(g-1)-1-(g-2)*2);
for (long int i=1;((g-1)*(g-1)+i)<=p;i++)
{
if ((i == 1 || i == g) && g != 1)
{
result+=5;
}
else if (g!=1)
{
result+=3;
}
}
}
}
else//решение третьего этапа
{
double o=i;
result=8*(o-1)+4+5*(o-1)*(o-1)*2+3*(o-1)*2+3*(o-1)*(o-1)*(o-1)+2*(o-1)*(o-1);//результат по формуле разрядности,только на высоту раную i-1
p=n-(o-1)*o*o;
g=bit(g,p,2);
if (g==1)
result+=8;
else
result+=8+(g-2)*2*5+3*((g-1)*(g-1)-1-(g-2)*2);
for (long int i=1;((g-1)*(g-1)+i)<=p;i++)
{
if ((i == 1 || i == g) && g != 1)
{
result+=5;
}
else if (g!=1)
{
result+=3;
}
}
}
cout <<result<< endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPG1hdGguaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBiaXQoaW50IGksaW50IG4saW50IHUpCnsKCWRvCgl7CgkJaT1pKzE7Cgl9d2hpbGUocG93KGksdSk8bik7CglyZXR1cm4gaTsKfQoKCmludCBtYWluKCkgewpkb3VibGUgbixyZXN1bHQscDsvL9C/0LXRgNC10LzQtdC90L3Ri9C1INC00LvRjyDRgNC10LfRg9C70YzRgtCw0YLQsCDQuCDQutC+0LvQuNGH0LXRgdGC0LLQviDQutGD0LHQuNC60L7QsizQvdCwINCy0YHRj9C60LjQuSDRgdC70YPRh9Cw0Lkg0LHQvtC70YzRiNC+0Lkg0YDQsNC30LzQtdGA0L3QvtGB0YLQuApsb25nIGxvbmcgaW50IGk9MCxnPTA7Ly/QvtCx0YrRj9Cy0LvRj9C10Lwg0L/QtdGA0LXQtdC90L3Ri9C1INC00LvRjyDRgNCw0LfRgNGP0LTQvdC+0YHRgtC10LkKY2luPj5uOwppPWJpdChpLG4sMyk7Ly/QvdCw0YXQvtC00LjQvCDRgNCw0LfRgNGP0LTQvdC+0YHRgtGMINC60YPQsdCwCmlmICgoaSppKihpLTEpKT49bikvL9C/0YDQvtCy0LXRgNC60LAg0YLRgNC10YLRjNC10LPQviDRjdGC0LDQv9CwCgl7CgkJaWYgKCgoaS0xKSooaS0xKSppKT49bikvL9C/0YDQvtCy0LXRgNC60LAg0L/QtdGA0LLQvtCz0L4g0Y3RgtCw0L/QsCDQuCDQtdGB0LvQuCDQv9GA0LDQstC00LAs0YLQviDRgNC10YjQtdC90LjQtSDQv9C10YDQstC+0LPQviDRjdGC0LDQv9CwCgkJewoJ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