public class SuanShiJieFa {
    static int num = 0;

    public static void f1(int a[], int k) {
        double q;
        double w;
        double e;
        if (k == a.length - 1) {
            q = a[0];
            w = a[1] * 1.00 / a[2];
            e = (a[3] * 100 + a[4] * 10 + a[5]) * 1.00 / (a[6] * 100 + a[7] * 10 + a[8]);
            if (q + w + e == 10) {
                num++;
            }
        }
        for (int i = k; i < a.length; i++) {
            {
                int temp = a[i];
                a[i] = a[k];
                a[k] = temp;
            }
            f1(a, k + 1);
            {
                int temp = a[i];
                a[i] = a[k];
                a[k] = temp;
            }
        }
    }

    public static void main(String[] args) {
        int a[] = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        f1(a, 0);
        System.out.println(num);
    }
}