#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)


int main() {
    int a[9] = {0};
    rep(i,9) cin >> a[i];
    int cntNone = 0;
    vector<int> indNone;
    vector<int> v;
    set<int> s;
    rep(i,9) s.insert(i+1);
    rep(i,9) {
        if (a[i] == -1) {
            cntNone ++;
            indNone.push_back(i);
        }
        else s.erase(a[i]);
    }
    for (auto i: s) v.push_back(i);
    int ans = 0;
    do
    {
        int b[9];
        rep(i,9) b[i] = a[i];
        rep(i,cntNone) {
            b[indNone[i]] = v[i];
        }
        //rep(i,9) cout << b[i] << ' ';
        //cout << endl;
        int b1 = b[0] + b[2] + b[5];
        int b2 = b[1] + b[4] + (b1 / 10);
        int b3 = b[3] + (b2 / 10);
        if (b1 % 10 != b[8]) continue;
        if (b2 % 10 != b[7]) continue;
        if (b3 % 10 != b[6]) continue;
        ans ++;
    } while (next_permutation( v.begin(), v.end() ) );
    cout << ans << endl;
}
