#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int num[9];
  rep(i, 9) cin >> num[i];
  vint vec;
  rep(i, 9) vec.push_back(i+1);
  int ans = 0;
  do {
    bool flag = true;
    rep(i, 9) if(num[i] != -1 && num[i] != vec[i]) flag = false;
    if(!flag) continue;
    int a = vec[0];
    int bc = vec[1]*10 + vec[2];
    int def = vec[3]*100 + vec[4]*10 + vec[5];
    int ghi = vec[6]*100 + vec[7]*10 + vec[8];
    if(a+bc+def == ghi) ans++;
  }while(next_permutation(all(vec)));
  cout << ans << endl;

  return 0;
}