#P8833. Counting Common Students in Courses

    ID: 21997 Type: Default 1000ms 256MiB

Counting Common Students in Courses

Counting Common Students in Courses

At Zhucheng Vocational College, two courses, \(A\) and \(B\), are offered. There are \(n\) students enrolled in course \(A\) and \(m\) students enrolled in course \(B\). The student IDs for course \(A\) are given as \(a_1, a_2, \dots, a_n\) and for course \(B\) as \(b_1, b_2, \dots, b_m\). Your task is to determine how many students have enrolled in both courses.

Note: For all test cases, \(n, m, a_i, b_i \leq 20\). Each course list contains unique student IDs.

inputFormat

The first line contains two integers \(n\) and \(m\), representing the number of students enrolled in courses \(A\) and \(B\) respectively. The second line contains \(n\) space-separated integers representing the IDs of students in course \(A\). The third line contains \(m\) space-separated integers representing the IDs of students in course \(B\).

outputFormat

Output a single integer, the number of students who are enrolled in both courses.

sample

3 3
1 2 3
2 3 4
2