#include<stdio.h>
int main()
{
int n, sum = 0, rem, a = 0, r;
while(scanf("%d",&n) == 1)
{
sum = 0;
a = 0;
r = 0;
while(n != 0)
{
sum = sum + n;
rem = n%3;
a = a + rem;
n = n/3;
}
r = a/2;
printf("%d\n",sum+r);
}
return 0;
}
Comments
Post a Comment