#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    scanf("%d",&t);
    vector<string> g[t+3];
    for(int i=0;i<t;++i){
        for(int j=0;j<3;++j){
            string s;
            cin>>s;
            g[i].push_back(s);
        }
    }

    int res = 0;

    for(int i=1;i<=1<<t;++i){
        int temp=0;
        unordered_set<string> st;
        for(int j=0;j<t;++j){
            if(i&(1<<j)){
                if(st.find(g[j][0])!=st.end()){
                    break;
                } else {
                    st.insert(g[j][0]);
                }
                if(st.find(g[j][1])!=st.end()){
                    break;
                } else {
                    st.insert(g[j][1]);
                }
                if(st.find(g[j][2])!=st.end()){
                    break;
                } else {
                    st.insert(g[j][2]);
                }
                ++temp;
                res=max(res,temp);
            }
        }
    }

    printf("%d\n",res);
}