#include <stdio.h>
int main()
{
    int n, t;
    scanf("%d", &n);
    int pin = n, gai = n; //p为瓶数  g为盖数
    while (gai / 3 != 0)
    {
        pin = pin + (gai / 3);
        t = gai;
        gai = (gai % 3) + (gai / 3); //换取的陪瓶子加上上次剩余的瓶盖
    }
    printf("%d", pin);
    return 0;
}
