import java.util.HashMap;
import java.util.Map;

public class Euler208 {
    public static void main(String[] args) {
        int steps = 70;
        Map<Long, Long> current = new HashMap<>();
        current.put(encodeState(0, 0, 0, 0, 0), 1L);
        for (int round = 0; round < steps; round++) {
            Map<Long, Long> next = new HashMap<>();
            for (var entry : current.entrySet()) {
                long key = entry.getKey();
                long count = entry.getValue();
                long[] s = decodeState(key);
                // Clockwise
                long cw = encodeState(s[2], s[3], s[4], -s[0], -s[1] - 1);
                next.merge(cw, count, Long::sum);
                // Anticlockwise
                long acw = encodeState(-s[3], -s[4] + 1, s[0], s[1], s[2]);
                next.merge(acw, count, Long::sum);
            }
            current = next;
        }
        long ans = 0;
        for (var entry : current.entrySet()) {
            long[] s = decodeState(entry.getKey());
            if (isClosed(s))
                ans += entry.getValue();
        }
        System.out.println(ans);
    }

    static boolean isClosed(long[] s) {
        return s[1] + s[4] == 0 && s[2] + s[3] == 0 && s[1] + s[2] == 0 && s[0] + s[1] == 0;
    }

    static long encodeState(long a, long b, long c, long d, long e) {
        return ((a + 70) * 141 * 141 * 141 * 141) + ((b + 70) * 141 * 141 * 141) + ((c + 70) * 141 * 141)
                + ((d + 70) * 141) + (e + 70);
    }

    static long[] decodeState(long key) {
        long e = key % 141 - 70;
        key /= 141;
        long d = key % 141 - 70;
        key /= 141;
        long c = key % 141 - 70;
        key /= 141;
        long b = key % 141 - 70;
        key /= 141;
        long a = key - 70;
        return new long[] { a, b, c, d, e };
    }
}
