#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int alpha[9];
    bool blank[9] = { false };
    
    for (int i = 0; i < 9; ++i) {
        cin >> alpha[i];
        if (alpha[i] == -1) {
            blank[i] = true;
        }
    }
    
    vector<int> v;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 0; j < 9; ++j) {
            if (alpha[j] == i)
                break;
            if (j == 8)
                v.push_back(i);
        }
    }
    
    int ans = 0;
    do {
        int s = 0, c, t;
        for (int i = 0; i < 9; ++i) {
            if (blank[i] == false)
                continue;
            alpha[i] = v[s++];
        }
        
        t = alpha[0] + alpha[2] + alpha[5];
        if (t % 10 != alpha[8])
            continue;
        c = t / 10;
        
        t = c + alpha[1] + alpha[4];
        if (t % 10 != alpha[7])
            continue;
        c = t / 10;
        
        t = c + alpha[3];
        if (t % 10 != alpha[6] || t >= 10)
            continue;
        
        ans++;
    } while(next_permutation(v.begin(), v.end()));
    
    cout << ans << endl;
    
    return 0;
}