LearnPy Hub
← Arena
AdvancedRating 2000

Match Students to Projects

Each student lists the projects they would accept. Each project takes at most one student and each student does at most one project. Print the largest number of students who can get a project.

Input

s, p and k; then k lines 'student project' (students 1 … s, projects 1 … p).

Output

One integer.

Sample 1

Input
3 3 4
1 1
2 1
3 2
3 3
Output
2

Sample 2

Input
2 1 2
1 1
2 1
Output
1
solution.py
Output appears here
Match Students to Projects · Python Arena problem · LearnPy Hub