#ifdef SU1
//#define _GLIBCXX_DEBUG
#endif

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forl(i, n) for (int i = 1; i <= int(n); i++)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define ft first
#define sc second
#define x first
#define y second

template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

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

const int N = 100 + 3;

int c[2][N];

inline bool read()
{
	forn(i, 2)
		forn(j, 6)
			assert(scanf("%d", &c[i][j]) == 1);
			//c[i][j] = rand() % 1000 + 1;
			
	return true;
}

int szs;
int s[N];

int a[N], b[N];

int used[N];

inline int use(int from, int s, int add)
{
	fore(i, from, szs - 1)
	{
		if (::s[i] == s && !used[i])
		{
			used[i] += add;			
			return i;
		}
		
		if (::s[i] > s) break;
	}
	
	return -1;
}

int ans;

set<pair<vector<int>, vector<int> > > z;

void solve(int idx, int i, int j)
{
	if (idx == szs)
	{
		vector<int> v1(a, a + 6);
		vector<int> v2(b, b + 6);
		
		if (v1 > v2) swap(v1, v2);
		
		z.insert(mp(v1, v2));
		ans++;
		return;
	}
	
	if (used[idx]) return solve(idx + 1, i, j);
	
	if (i < 6)
	{
		a[i] = s[idx] - b[0];
		
		vector<int> v;
		
		forn(k, j)
		{
			int x = use(idx, a[i] + b[k], +1);

			if (x == -1)
				break;
			
			v.pb(x);
		}
		
		if (sz(v) == j)
			solve(idx + 1, i + 1, j);			
			
		forn(k, sz(v))
			used[v[k]]--;
	}
	
	if (j < 6)
	{
		b[j] = s[idx] - a[0];
		
		vector<int> v;
		
		forn(k, i)
		{
			int x = use(idx, a[k] + b[j], +1);
			
			if (x == -1)
				break;
				
			v.pb(x);
		}
			
		if (sz(v) == i)
			solve(idx + 1, i, j + 1);
			
		forn(k, sz(v))
			used[v[k]]--;
	}
}

inline void solve()
{
	forn(i, 6)
		forn(j, 6)
			s[szs++] = c[0][i] + c[1][j];
			
	sort(s, s + szs);
	
	ans = 0;
	
	for (a[0] = 0; a[0] <= s[0]; a[0]++)
	{
		b[0] = s[0] - a[0];
		if (b[0] < a[0]) continue;
		
		used[0]++;
		solve(1, 1, 1);
		used[0]--;
	}

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

#ifdef SU1
	#include <windows.h>
#endif

int main()
{
#ifdef SU1
	assert(freopen("input.txt", "rt", stdin));
//	assert(freopen("output.txt", "wt", stdout));
	srand(GetTickCount());
#endif

	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(5);

	assert(read());
	solve();
	
#ifdef SU1
	cerr << "=== TIME : " << clock() << " ===" << endl;
#endif
	return 0;
}
