import java.util.ArrayList;
import java.util.List;

public class Euler376 {

    static class Transition {
        int nA, nB, nC;
        int maxWBa, maxWCb, maxWAc;

        Transition(int nA, int nB, int nC, int adBa, int adCb, int adAc) {
            this.nA = nA;
            this.nB = nB;
            this.nC = nC;
            this.maxWBa = adBa;
            this.maxWCb = adCb;
            this.maxWAc = adAc;
        }
    }

    @SuppressWarnings("unchecked")
    static List<Transition>[] buildTransitions() {
        List<Transition>[] transitions = new ArrayList[343];
        for (int i = 0; i < 343; i++)
            transitions[i] = new ArrayList<>();

        for (int usedA = 0; usedA <= 6; usedA++) {
            for (int usedB = 0; usedB <= 6; usedB++) {
                for (int usedC = 0; usedC <= 6; usedC++) {
                    int idx = (usedA * 7 + usedB) * 7 + usedC;
                    for (int addA = 0; addA <= 6 - usedA; addA++) {
                        for (int addB = 0; addB <= 6 - usedB; addB++) {
                            for (int addC = 0; addC <= 6 - usedC; addC++) {
                                transitions[idx].add(new Transition(
                                        usedA + addA,
                                        usedB + addB,
                                        usedC + addC,
                                        addB * usedA,
                                        addC * usedB,
                                        addA * usedC));
                            }
                        }
                    }
                }
            }
        }
        return transitions;
    }

    static String solve() {
        List<Transition>[] transitions = buildTransitions();
        int n = 30;

        long[] current = new long[10485760];
        int[] currentKeys = new int[2000000];
        int currentSize = 0;

        current[0] = 1;
        currentKeys[currentSize++] = 0;

        long[] next = new long[10485760];
        int[] nextKeys = new int[2000000];

        for (int value = 1; value <= n; value++) {
            int nextSize = 0;
            int valuesLeftAfter = n - value;

            for (int i = 0; i < currentSize; i++) {
                int key = currentKeys[i];
                long ways = current[key];
                current[key] = 0; // Clear for next reuse

                int usedA = key & 7;
                int usedB = (key >> 3) & 7;
                int usedC = (key >> 6) & 7;
                int wBa = (key >> 9) & 31;
                int wCb = (key >> 14) & 31;
                int wAc = (key >> 19) & 31;

                int idx = (usedA * 7 + usedB) * 7 + usedC;
                for (Transition tr : transitions[idx]) {
                    if (valuesLeftAfter == 0 && (tr.nA != 6 || tr.nB != 6 || tr.nC != 6)) {
                        continue;
                    }

                    int nwBa = wBa + tr.maxWBa;
                    int nwCb = wCb + tr.maxWCb;
                    int nwAc = wAc + tr.maxWAc;

                    if (nwBa > 19)
                        nwBa = 19;
                    if (nwCb > 19)
                        nwCb = 19;
                    if (nwAc > 19)
                        nwAc = 19;

                    if (nwBa + (6 - tr.nB) * 6 < 19)
                        continue;
                    if (nwCb + (6 - tr.nC) * 6 < 19)
                        continue;
                    if (nwAc + (6 - tr.nA) * 6 < 19)
                        continue;

                    int nkey = tr.nA | (tr.nB << 3) | (tr.nC << 6) | (nwBa << 9) | (nwCb << 14) | (nwAc << 19);

                    if (next[nkey] == 0) {
                        nextKeys[nextSize++] = nkey;
                    }
                    next[nkey] += ways;
                }
            }

            long[] tempArr = current;
            current = next;
            next = tempArr;

            int[] tempKeys = currentKeys;
            currentKeys = nextKeys;
            nextKeys = tempKeys;

            currentSize = nextSize;
        }

        int terminal = 6 | (6 << 3) | (6 << 6) | (19 << 9) | (19 << 14) | (19 << 19);
        long ways = current[terminal];
        // Uses unsigned division because it might exceed signed max.
        // Long.divideUnsigned works properly.
        long ans = Long.divideUnsigned(ways, 3);

        return Long.toUnsignedString(ans);
    }

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