#include <iostream>
using namespace std;

int a[12] = {0};
int vis[14] = {0};
int count;
void dfs(int step)
{
    if (step == 3)
    {
        if (a[0] + a[1] != a[2])
            return;
    }

    if (step == 6)
    {
        if (a[3] - a[4] != a[5])
            return;
    }

    if (step == 9)
    {
        if (a[6] * a[7] != a[8])
            return;
    }

    if (step == 13)
    {
        if (a[11] * a[10] == a[9])
        {
            count++;
        }
        return;
    }
    for (int i = 1; i < 14; i++)
    {
        if (vis[i] == 0)
        {
            vis[i] = 1;
            a[step] = i;
            dfs(step + 1);
            vis[i] = 0;
        }
    }
}
int main()
{

    count = 0;
    dfs(0);
    cout << count;
    return 0;
}
