import java.math.BigInteger;

public class Euler219 {
    public static void main(String[] args) {
        long n = 1000000000L;
        if (n <= 1) {
            System.out.println(0);
            return;
        }
        long internalNodes = n - 1;
        // multiplicity[c] = multiplicity[c-1] + multiplicity[c-4], multiplicity[0] = 1
        long used = 0;
        BigInteger totalCost = BigInteger.ZERO;
        BigInteger[] mult = new BigInteger[200];
        mult[0] = BigInteger.ONE;
        int cost = 0;
        while (used < internalNodes) {
            if (cost >= mult.length) {
                BigInteger[] newMult = new BigInteger[mult.length + 100];
                System.arraycopy(mult, 0, newMult, 0, mult.length);
                mult = newMult;
            }
            if (cost > 0) {
                mult[cost] = mult[cost - 1];
                if (cost >= 4)
                    mult[cost] = mult[cost].add(mult[cost - 4]);
            }
            long remaining = internalNodes - used;
            BigInteger rem = BigInteger.valueOf(remaining);
            long take;
            if (mult[cost].compareTo(rem) >= 0)
                take = remaining;
            else
                take = mult[cost].longValueExact();
            totalCost = totalCost.add(BigInteger.valueOf(take).multiply(BigInteger.valueOf(cost)));
            used += take;
            cost++;
        }
        BigInteger answer = BigInteger.valueOf(5).multiply(BigInteger.valueOf(internalNodes)).add(totalCost);
        System.out.println(answer);
    }
}
