#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

int check(vector<int> &mat,vector<int> &vec) {
  rep(i,9) if( mat[i] != -1 && mat[i] != vec[i] ) return 0;
  int a = vec[0] + ( vec[1] * 10 + vec[2] ) + ( vec[3] * 100 + vec[4] * 10 + vec[5] );
  int b = vec[6] * 100 + vec[7] * 10 + vec[8];
  return a == b;
}

int main() {
  vector<int> mat(9);
  rep(i,9) cin >> mat[i];
  vector<int> vec(9);
  REP(i,1,10) vec[i-1] = i;
  int cnt = 0;
  do {
    cnt += check(mat,vec);
  } while( next_permutation(vec.begin(),vec.end()) );
  cout << cnt << endl;
  return 0;
}