public class Euler209 {
    public static void main(String[] args) {
        boolean[] visited = new boolean[64];
        java.util.List<Integer> cycleLengths = new java.util.ArrayList<>();
        for (int s = 0; s < 64; s++) {
            if (visited[s])
                continue;
            int len = 0, cur = s;
            while (!visited[cur]) {
                visited[cur] = true;
                cur = nextState(cur);
                len++;
            }
            cycleLengths.add(len);
        }
        long ans = 1;
        for (int L : cycleLengths)
            ans *= countCycle(L);
        System.out.println(ans);
    }

    static int nextState(int x) {
        int a = (x >> 5) & 1, b = (x >> 4) & 1, c = (x >> 3) & 1;
        int g = a ^ (b & c);
        return ((x & 31) << 1) | g;
    }

    static long countCycle(int L) {
        long[] fib = new long[L + 2];
        fib[1] = 1;
        for (int i = 2; i <= L + 1; i++)
            fib[i] = fib[i - 1] + fib[i - 2];
        return fib[L - 1] + fib[L + 1];
    }
}
