// Arup Guha
// 1/22/2017
// Solution to 2017 January USACO Bronze problem: Hoof, Paper Scissors!

import java.util.*;
import java.io.*;

public class hps {

	public static void main(String[] args) throws Exception {

		// Read # of games.
		Scanner stdin = new Scanner(new File("hps.in"));
		int[] freq = new int[6];
		int n = stdin.nextInt();

		// Update games with winners.
		for (int i=0; i<n; i++) {
			int a = stdin.nextInt();
			int b = stdin.nextInt();
			if (a == b) continue;
			int extra = 1;
			if (a+b == 3 || (a==3 && b ==1))
				extra = 0;
			freq[2*(a-1)+extra]++;
		}

		// Here is our result, the larger of these two.
		PrintWriter out = new PrintWriter(new FileWriter("hps.out"));
		out.println(Math.max(freq[0]+freq[3]+freq[4], freq[2]+freq[1]+freq[5]));

		out.close();
		stdin.close();
	}
}
