// Arup Guha
// 2/16/2017
// Solution to 2017 February USACO Bronze Problem: Why Did the Cow Cross the Road?

import java.util.*;
import java.io.*;

public class crossroad {

	public static void main(String[] args) throws Exception {

		// Read input.
		Scanner stdin = new Scanner(new File("crossroad.in"));
		int n = stdin.nextInt();

		int res = 0;

		// All cows are at -1 (unknown)
		int[] loc = new int[10];
		Arrays.fill(loc,-1);

		// Update where each cow is, adding if last time they were on the other side of the road.
		for (int i=0; i<n; i++) {
			int cow = stdin.nextInt()-1;
			int now = stdin.nextInt();
			if (loc[cow] != -1 && loc[cow] != now) res++;
			loc[cow] = now;
		}

		// Output the result.
		PrintWriter out = new PrintWriter(new FileWriter("crossroad.out"));
		out.println(res);
		out.close();
		stdin.close();
	}
}