#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);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpewogICAgaW50IHQ7CiAgICBzY2FuZigiJWQiLCZ0KTsKICAgIHZlY3RvcjxzdHJpbmc+IGdbdCszXTsKICAgIGZvcihpbnQgaT0wO2k8dDsrK2kpewogICAgICAgIGZvcihpbnQgaj0wO2o8MzsrK2opewogICAgICAgICAgICBzdHJpbmcgczsKICAgICAgICAgICAgY2luPj5zOwogICAgICAgICAgICBnW2ldLnB1c2hfYmFjayhzKTsKICAgICAgICB9CiAgICB9CgogICAgaW50IHJlcyA9IDA7CgogICAgZm9yKGludCBpPTE7aTw9MTw8dDsrK2kpewogICAgICAgIGludCB0ZW1wPTA7CiAgICAgICAgdW5vcmRlcmVkX3NldDxzdHJpbmc+IHN0OwogICAgICAgIGZvcihpbnQgaj0wO2o8dDsrK2opewogICAgICAgICAgICBpZihpJigxPDxqKSl7CiAgICAgICAgICAgICAgICBpZihzdC5maW5kKGdbal1bMF0pIT1zdC5lbmQoKSl7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIHN0Lmluc2VydChnW2pdWzBdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmKHN0LmZpbmQoZ1tqXVsxXSkhPXN0LmVuZCgpKXsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgc3QuaW5zZXJ0KGdbal1bMV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYoc3QuZmluZChnW2pdWzJdKSE9c3QuZW5kKCkpewogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBzdC5pbnNlcnQoZ1tqXVsyXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICArK3RlbXA7CiAgICAgICAgICAgICAgICByZXM9bWF4KHJlcyx0ZW1wKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBwcmludGYoIiVkXG4iLHJlcyk7Cn0=
NwpnZXJvc3RyYXRvcyBzY29ycGlvIHNoYW1nc2hhbWcKemFpdHNldiBzaWx2ZXJiZXJnIGNvdXN0ZWF1CnphaXRzZXYgcGV0ZXJzZW4gc2hhbWdzaGFtZwpjbGlwcGVyIHBldGVyc2VuIHNoYW1nc2hhbWcKY2xpcHBlciBiYWtpcmVsbGkgdmFzaWxpYWRpCnNpbHZlcmJlcmcgYXRuIGRvbGx5CmtudXRoIGRpamtzdHJhIGJlbGxtYW4=
7
gerostratos scorpio shamgshamg
zaitsev silverberg cousteau
zaitsev petersen shamgshamg
clipper petersen shamgshamg
clipper bakirelli vasiliadi
silverberg atn dolly
knuth dijkstra bellman