import java.io.*;
import java.util.*;

public class history_gk_stress {
    static Scanner in;
    static PrintWriter out;

    static int[] points = new int[]{0, 1, 3};
    static int[] conj = new int[]{3, 1, 100, 0};

    Map<W, Integer> cache = new HashMap<W, Integer>();

    static List<int[]>[][] variants;

    static class W {
        public int[] a;

        public W(int[] a) {
            this.a = a;
        }
        
        @Override
        public int hashCode() {
            return Arrays.hashCode(a);
        }

        @Override
        public boolean equals(Object o) {
            return Arrays.equals(a, ((W) o).a);
        }
    }

    List<int[]> getVariants(int i, int j) {
        if (i + j != 0) {
            if (j > 3 * i) {
                variants[i][j] = Collections.emptyList();
            } else {
                variants[i][j] = new ArrayList<int[]>();
                for (int p : points) {
                    if (0 <= j - p) {
                        for (int[] l : getVariants(i - 1, j - p)) {
                            int[] nl = new int[l.length + 1];
                            for (int x = 0; x < i - 1; x++) {
                                solveGets++;
                                nl[x] = l[x];
                            }
                            nl[i - 1] = p;
                            variants[i][j].add(nl);
                        }
                    }
                }
            }
        }
        return variants[i][j];
    }

    int solveHits = 0;
    int solveGets = 0;
    int solveCalc = 0;
    int solveZero = 0;

    int solve(int[] t) {
        solveGets += t.length;
        //Arrays.sort(t);
        W w = new W(t);

        Integer ans = cache.get(w);
//        System.out.println("===== " + Arrays.toString(t) + " " + ans);

        if (ans != null) {
            solveHits++;
            return ans;
        }

        int n = t.length;
        int s = 0;
        for (int i : t) {
            s += i;
        }
        int plays = n * (n - 1) / 2;
        int result = 0;
        if (s < 2 * plays || 3 * plays < s) {
            cache.put(w, 0);
            return 0;
        }
        for (int[] v : getVariants(n - 1, t[n - 1])) {
            solveCalc += n - 1;
            int[] l = new int[n - 1];
            int i = 0;
            for (i = 0; i < n - 1; i++) {
                int z = t[i] - conj[v[i]];
                if (z < 0) break;
                l[i] = z;
            }
            if (i == n - 1) {
                result += solve(l);
            }
        }
        solveCalc++;
        if (result == 0) {
            solveZero++;
        }
        cache.put(w, result);
        return result;
    }

    public int run(int ... t) {
        int n = t.length;

        variants = new List[n + 1][3 * n + 1];
        variants[0][0] = Collections.singletonList(new int[0]);

        cache.put(new W(new int[0]), 1);

        return solve(t);
    }

    public static void main(String[] args) throws IOException {
        long max = 0;

        int count = 0;
        int[] t = new int[]{5, 6, 7, 8, 9, 10, 11, 11};
        long best = 0;
        for (int i = 0; i < t.length * 10; i++) {
            while (true) {
                history_gk_stress me = new history_gk_stress();
                t[i % t.length] -= 1;
                me.run(t.clone());
                if (best < me.solveGets) {
                    System.out.println(Arrays.toString(t) + " " + me.solveGets);
                    best = me.solveGets;
                } else {
                    t[i % t.length] += 1;
                    break;
                }
            } 
            while (true) {
                history_gk_stress me = new history_gk_stress();
                t[i % t.length] += 1;
                me.run(t.clone());
                if (best < me.solveGets) {
                    System.out.println(Arrays.toString(t) + " " + me.solveGets);
                    best = me.solveGets;
                } else {
                    t[i % t.length] -= 1;
                    break;
                }
            } 
            System.out.println(i);
        }
        /*
        int n = 8;
        for (int i1 = 6; i1 <= n * 3; i1++) {
            for (int i2 = i1; i2 <= n * 3; i2++) {
                 for (int i3 = i2; i3 <= n * 3; i3++) {
                    for (int i4 = i3; i4 <= n * 3; i4++) {
                        for (int i5 = i4; i5 <= n * 3; i5++) {
                            for (int i6 = i5; i6 <= n * 3; i6++) {
                                for (int i7 = i6; i7 <= n * 3; i7++) {
                                    for (int i8 = i7; i8 <= n * 3; i8++) {
                                        for (int i9 = i8; i9 <= n * 3; i9++) {
                                            int[] q = new int[]{i1, i2, i3, i4, i5, i6, i7, i8, i9};
                                            history_gk_stress me = new history_gk_stress();
                                            me.run(q);
                                            long result = me.solveCalc;
                                            count++;
                                            if (max < result && result != 0) {
                                                System.out.println(Arrays.toString(q) + " " + result + " " + me.solveGets);
                                                max = result;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                 }
            }
        }
        */
        System.out.println(count);
    }
}
