#K8251. Common Elements Count

    ID: 35991 Type: Default 1000ms 256MiB

Common Elements Count

Common Elements Count

You are given two sets of integers. The task is to count how many common elements they have. Implement a function that computes the intersection of the two sets and returns its size.

The input is given via standard input (stdin) and consists of four lines:

  • The first line contains an integer \( n_1 \) indicating the number of elements in the first set.
  • The second line contains \( n_1 \) space-separated integers representing the first set.
  • The third line contains an integer \( n_2 \) indicating the number of elements in the second set.
  • The fourth line contains \( n_2 \) space-separated integers representing the second set.

The output should be a single integer printed to standard output (stdout) representing the number of common elements between the two sets.

inputFormat

The input is read from standard input (stdin) and has the following format:

 n1
 a1 a2 ... an1
 n2
 b1 b2 ... bn2

Here, n1 is the number of elements in the first set (followed by the n1 integers) and n2 is the number of elements in the second set (followed by n2 integers).

outputFormat

The output is a single integer printed to standard output (stdout), representing the count of common elements between the two sets.

## sample
8
1 2 3 4 5 6 7 8
6
5 6 7 8 9 10
4