import java.util.concurrent.*;
import java.math.BigInteger;

public class Euler282 {
    static final long MOD_MAIN = 1475789056L;

    static long power(long base, long exp, long mod) {
        long res = 1;
        base %= mod;
        while (exp > 0) {
            if (exp % 2 == 1) {
                // Using BigInteger for 128-bit multiplication equivalent to avoid overflow
                res = BigInteger.valueOf(res).multiply(BigInteger.valueOf(base)).mod(BigInteger.valueOf(mod))
                        .longValue();
            }
            base = BigInteger.valueOf(base).multiply(BigInteger.valueOf(base)).mod(BigInteger.valueOf(mod)).longValue();
            exp /= 2;
        }
        return res;
    }

    static long getPhi(long n) {
        long result = n;
        for (long i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                while (n % i == 0)
                    n /= i;
                result -= result / i;
            }
        }
        if (n > 1)
            result -= result / n;
        return result;
    }

    static long hyperTower2(long height, long m) {
        if (m == 1)
            return 0;
        if (height == 0)
            return 1 % m;
        if (height == 1)
            return 2 % m;
        if (height == 2)
            return 4 % m;
        if (height == 3)
            return 16 % m;
        if (height == 4)
            return 65536 % m;

        long phi = getPhi(m);
        long exponentVal = hyperTower2(height - 1, phi);

        long effExponent = exponentVal + phi;
        return power(2, effExponent, m);
    }

    static long solveN0() {
        return 1;
    }

    static long solveN1() {
        return 3;
    }

    static long solveN2() {
        return 7;
    }

    static long solveN3() {
        return 61;
    }

    static long solveN4() {
        long term = hyperTower2(7, MOD_MAIN);
        return (term - 3 + MOD_MAIN) % MOD_MAIN;
    }

    static long solveLargeN() {
        long term = hyperTower2(200, MOD_MAIN);
        return (term - 3 + MOD_MAIN) % MOD_MAIN;
    }

    public static String solve() {
        ExecutorService executor = Executors.newFixedThreadPool(7);
        try {
            Future<Long> f0 = executor.submit(Euler282::solveN0);
            Future<Long> f1 = executor.submit(Euler282::solveN1);
            Future<Long> f2 = executor.submit(Euler282::solveN2);
            Future<Long> f3 = executor.submit(Euler282::solveN3);
            Future<Long> f4 = executor.submit(Euler282::solveN4);
            Future<Long> f5 = executor.submit(Euler282::solveLargeN);
            Future<Long> f6 = executor.submit(Euler282::solveLargeN);

            long s0 = f0.get();
            long s1 = f1.get();
            long s2 = f2.get();
            long s3 = f3.get();
            long s4 = f4.get();
            long s5 = f5.get();
            long s6 = f6.get();

            long total = (s0 + s1 + s2 + s3 + s4 + s5 + s6) % MOD_MAIN;
            return String.valueOf(total);
        } catch (Exception e) {
            e.printStackTrace();
            return "Error";
        } finally {
            executor.shutdown();
        }
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
