// Arup Guha
// 11/15/2014
// Solution to 2014 South East Regional D2 Problem: Top 25

import java.util.*;

public class top25 {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Get first list.
		String[] list1 = new String[n];
		for (int i=0; i<n; i++)
			list1[i] = stdin.next();

		// Get second list.
		String[] list2 = new String[n];
		for (int i=0; i<n; i++)
			list2[i] = stdin.next();

		// Store what we've seen.
		HashSet<String> seen = new HashSet<String>();
		int numTwos = 0, total = 0;
		for (int i=0; i<n; i++) {

			// Process list one item.
			if (seen.contains(list1[i]))
				numTwos++;
			else
				seen.add(list1[i]);

			// Process list two item.
			if (seen.contains(list2[i]))
				numTwos++;
			else
				seen.add(list2[i]);

			// Did one more group.
			total++;

			// Perfect matches - output and reset!
			if (total == numTwos) {
				System.out.println(total);
				numTwos = 0;
				total = 0;
				seen = new HashSet<String>();
			}
		}
	}
}