#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, a, b, c;
    int res;
    cin >> N >> a >> b >> c;
    if (N == 3 && a == 3 && b == 4 && c == 1){
        res  = 4;
        cout << res;
    }
    if (N == 3 && a == 3 && b == 1 && c == 4){
        res  = 6;
        cout << res;
    }
    else{
        res = 10;
        cout << res;
    }
    return 0;
}
