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

string strs[10005][2];
map <string,int> sidioms;
map <string,int> eidioms;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		string ts1;
		string ts2;
		cin>>strs[i][0]>>ts1>>ts2>>strs[i][1];
		sidioms[strs[i][0]]++;
		eidioms[strs[i][1]]++;
	}
	int cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++){
		int t1 = sidioms[strs[i][0]];
		int t2 = eidioms[strs[i][1]];
		if(t1==0||t2==0){
			continue;
		}else if(t1==1&&t2==1){
			continue;
		}else{
			if(t2>t1){
				int t = t2 / 2;
				if(t>t1){
					cnt1 += t1;
				}else{
					cnt1 += t;
				}
			}else if(t1>t2){
				int t = t1 / 2;
				if(t>t2){
					cnt2 += t2;
				}else{
					cnt2 += t;
				}
			}else{
				if(cnt1<cnt2){
					cnt1 += t1 / 2;
				}else{
					cnt2 += t1 / 2;
				}
			}
		}
	}
	cout<<(min(cnt1,cnt2))/2;
	return 0; 
}