#include <bits/stdc++.h>

using namespace std;

string trim(const string& s) {
    std::regex trimRegex("^\\s+|\\s+$");
    return std::regex_replace(s, trimRegex, "");
}

string readString(ifstream& f) {
    string s;
    if (!getline(f, s)) {
        s = "";
    }
    return trim(s);
}

int main (int argc, char** argv) {
    if (argc < 4) return 0;
    ifstream inS(argv[1]), solS(argv[2]), contS(argv[3]);
    // input; correct output; contestant's output

    string c1, c2, c3;// correct output integers as strings
    solS >> c1 >> c2 >> c3;

    string s1 = readString(contS);
    string s2 = readString(contS);
    string s3 = readString(contS);

    int correct = 0;
    if (c1 == s1) {
        correct++;
        cerr << "Line 1 is correct\n";
    } else {
        cerr << "Line 1 is wrong\n";
    }

    if (c2 == s2) {
        correct++;
        cerr << "Line 2 is correct\n";
    } else {
        cerr << "Line 2 is wrong\n";
    }

    if (c3 == s3) {
        correct++;
        cerr << "Line 3 is correct\n";
    } else {
        cerr << "Line 3 is wrong\n";
    }


    if (correct == 3) cout << 1.0 << endl;
    else if (correct == 2) cout << 2.0/3.0 << endl;
    else if (correct == 1) cout << 1.0/3.0 << endl;
    else cout << 0.0 << endl;

    return 0;
}
