#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cassert>
#include <stack>
#include <cstdlib>
#include <bitset>
#include <cmath>

#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define pb push_back
#define all(a) a.begin(),a.end()
#define sz(a) int(a.size())
#define mp make_pair

using namespace std;

typedef long long li;
typedef long double ld;

typedef pair<int,int> pt;
#define ft first
#define sc second

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;

//#define TASK_NAME ""

int a[6];
int b[6];

const int N = 5005;
int sumcnt[N];

bool read() {
	forn(i, 6)
		if (!(cin >> a[i]))
			return false;
	forn(i, 6)
		cin >> b[i];
	return true;
}

int c[6], d[6];

typedef unsigned long long uli;

set <pair<uli,uli> > s;

void rec(int cpos, int dpos, int pos, uli cmask, uli dmask) {
	while (sumcnt[pos] == 0)
		pos++;

	if (cpos < 6) {
		c[cpos] = pos - d[0];
		if (c[cpos] >= c[cpos - 1]) {
			bool good = true;
			vector <int> v;
			forn(i, dpos) {
				int sum = c[cpos] + d[i];
				if (sumcnt[sum] == 0) {
					good = false;
				} else {
					v.pb(sum);
					sumcnt[sum]--;
				}
			}

			if (good)
				rec(cpos + 1, dpos, pos, cmask * 1001 + c[cpos], dmask);

			forn(i, sz(v))
				sumcnt[v[i]]++;
		}
	}

	if (dpos < 6) {
		d[dpos] = pos - c[0];
		if (d[dpos] >= d[dpos - 1]) {
			bool good = true;
			vector <int> v;
			forn(i, cpos) {
				int sum = d[dpos] + c[i];
				if (sumcnt[sum] == 0) {
					good = false;
				} else {
					v.pb(sum);
					sumcnt[sum]--;
				}
			}

			if (good)
				rec(cpos, dpos + 1, pos, cmask, dmask * 1001 + d[dpos]);

			forn(i, sz(v))
				sumcnt[v[i]]++;
		}
	}

	if (cpos == 6 && dpos == 6)
		s.insert(mp(min(cmask, dmask), max(cmask, dmask)));
}

void solve() {
	forn(i, 6)
		forn(j, 6)
			sumcnt[a[i] + b[j]] ++;

	int sm = a[0] + b[0];

	forn(i, sm + 1) {
		c[0] = i;
		d[0] = sm - i;
		sumcnt[sm]--;
		rec(1, 1, sm, c[0], d[0]);
		sumcnt[sm]++;
	}

	cout << sz(s) << endl;
}

int main() {
#ifdef TASK_NAME
	freopen(TASK_NAME ".in", "r", stdin);
	freopen(TASK_NAME ".out", "w", stdout);
#endif

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

	while (read())
		solve();

	return 0;
}