import java.util.*;

public class Euler928 {

    static final int[] kCardChoose = { 1, 4, 6, 4, 1 };
    static final int[][] kSubChoose = {
            { 1, 0, 0, 0, 0 },
            { 1, 1, 0, 0, 0 },
            { 1, 2, 1, 0, 0 },
            { 1, 3, 3, 1, 0 },
            { 1, 4, 6, 4, 1 }
    };

    static class HalfState {
        int handScore = 0;
        int pairScore = 0;
        int runScore = 0;
        int base = 0;

        int prefixLen = 0;
        int prefixProd = 1;
        int prefixScore = 0;

        int suffixLen = 0;
        int suffixProd = 1;
        int suffixScore = 0;

        int[] poly = new int[16];
        int[] polyRev = new int[16];

        long handMultiplicity = 0;
    }

    static HalfState makeHalfState(int[] counts, int[] values) {
        int n = counts.length;
        HalfState st = new HalfState();

        st.handMultiplicity = 1;

        for (int i = 0; i < n; ++i) {
            int c = counts[i];
            st.handScore += values[i] * c;
            st.pairScore += c * (c - 1);
            st.handMultiplicity *= kCardChoose[c];
        }

        int len = 0;
        int prod = 1;
        for (int i = 0; i < n; ++i) {
            int c = counts[i];
            if (c == 0) {
                if (len >= 3)
                    st.runScore += len * prod;
                len = 0;
                prod = 1;
            } else {
                len++;
                prod *= c;
            }
        }
        if (len >= 3)
            st.runScore += len * prod;

        st.prefixLen = 0;
        st.prefixProd = 1;
        while (st.prefixLen < n && counts[st.prefixLen] > 0) {
            st.prefixProd *= counts[st.prefixLen];
            st.prefixLen++;
        }
        st.prefixScore = st.prefixLen >= 3 ? (st.prefixLen * st.prefixProd) : 0;

        st.suffixLen = 0;
        st.suffixProd = 1;
        int idx = n - 1;
        while (idx >= 0 && counts[idx] > 0) {
            st.suffixProd *= counts[idx];
            st.suffixLen++;
            idx--;
        }
        st.suffixScore = st.suffixLen >= 3 ? (st.suffixLen * st.suffixProd) : 0;

        int[] ways = new int[16];
        ways[0] = 1;

        for (int j = 0; j < n; ++j) {
            int c = counts[j];
            int v = values[j];

            int[] next = new int[16];
            for (int s = 0; s <= 15; ++s) {
                if (ways[s] == 0)
                    continue;
                for (int d = 0; d <= c; ++d) {
                    int t = s + d * v;
                    if (t > 15)
                        break;
                    next[t] += ways[s] * kSubChoose[c][d];
                }
            }
            ways = next;
        }

        for (int s = 0; s <= 15; ++s) {
            st.poly[s] = ways[s];
            st.polyRev[s] = ways[15 - s];
        }

        st.base = st.handScore - st.pairScore - st.runScore;

        return st;
    }

    static void rec(int idx, int[] counts, int[] values, List<HalfState> states) {
        if (idx == counts.length) {
            states.add(makeHalfState(counts, values));
            return;
        }
        for (int c = 0; c <= 4; ++c) {
            counts[idx] = c;
            rec(idx + 1, counts, values, states);
        }
    }

    static List<HalfState> enumerateHalfStates(int[] values) {
        List<HalfState> states = new ArrayList<>();
        int[] counts = new int[values.length];
        rec(0, counts, values, states);
        return states;
    }

    static long countEqualMitm(int[] values) {
        int n = values.length;
        int split = n / 2;

        int[] leftValues = Arrays.copyOfRange(values, 0, split);
        int[] rightValues = Arrays.copyOfRange(values, split, n);

        List<HalfState> left = enumerateHalfStates(leftValues);
        List<HalfState> right = enumerateHalfStates(rightValues);

        long total = 0;

        for (HalfState L : left) {
            for (HalfState R : right) {
                int adjust = 0;
                if (L.suffixLen > 0 && R.prefixLen > 0) {
                    int mergedLen = L.suffixLen + R.prefixLen;
                    int mergedProd = L.suffixProd * R.prefixProd;
                    int mergedScore = (mergedLen >= 3) ? (mergedLen * mergedProd) : 0;
                    adjust = mergedScore - L.suffixScore - R.prefixScore;
                }

                int targetTwice = L.base + R.base - adjust;
                if (targetTwice < 0 || targetTwice > 340 || (targetTwice & 1) != 0) {
                    continue;
                }

                int targetF = targetTwice / 2;
                long f = 0;

                for (int k = 0; k <= 15; ++k) {
                    f += (long) L.poly[k] * R.polyRev[k];
                    if (f > targetF) {
                        break;
                    }
                }

                if (f == targetF) {
                    total += L.handMultiplicity * R.handMultiplicity;
                }
            }
        }

        return total - 1;
    }

    public static String solve() {
        int[] values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10 };
        return Long.toString(countEqualMitm(values));
    }

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