#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


int a[9];
bool eval() {
	if (a[6] * 100 + a[7] * 10 + a[8] == a[0] + a[1] * 10 + a[2] + a[3] * 100 + a[4] * 10 + a[5])
		return true;
	else return false;
}

signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int ans = 0;
	VI tmp,noot,no;
	REP(i, 9) {
		cin >> a[i];
		if (a[i] != -1)tmp.push_back(a[i]);
		else no.push_back(i);
	}
	eFOR(i, 1, 9) {
		bool f = false;
		REP(j, tmp.size()) {
			if (tmp[j] == i)f = true;
		}
		if (!f)noot.push_back(i);
	}
	//REP(i, not.size())cout << not[i] << " ";
	do {
		REP(i, noot.size()) {
			//cout << not[i] << " ";
			a[no[i]] = noot[i];
		}
		//cout << endl;
		if (eval())ans++;
	} while (next_permutation(noot.begin(),noot.end()));

	cout << ans << endl;

	return 0;
}


