#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int n[9];

int solve(int now, vector<int> m, vector<bool> b){
    if(now == 9){
        if(m[0] + 10*m[1]+m[2] +100*m[3]+10*m[4]+m[5] == 100*m[6]+10*m[7]+m[8]) return 1;
        return 0;
    }
    if(n[now] != -1) return solve(now+1, m, b);

    int re = 0;
    for(int i=0; i<9; i++){
        if(b[i] == true) continue;
        b[i] = true;
        m[now] = i+1;
        re += solve(now+1, m, b);
        b[i] = false;
        m[now] = -1;
    }
    return re;
}

int main(){
    
    vector<int> m;
    vector<bool> b;
    for(int i=0; i<9; i++) b.push_back(false);

    for(int i=0; i<9; i++){
        cin >> n[i];
        m.push_back(n[i]);
        if(n[i] != -1) b[n[i]-1] = true;
    }

    cout << solve(0, m, b) << endl;
    
    return 0;
}
