Hide

Problem C
Double Agent Conference

Reed Der has finished organizing this year’s Double Agent Conference. The conference consists of a morning event, an afternoon event, and an evening event for local double agents to attend.

Reed wants to know how many double agents attended at least one event, so he set up a booth for the double agents to check into before each event. Each double agent checks into an event by scanning a finger, which the system associates with a unique ID number. For extra security, no one can leave any event after it starts, so that no one checks in twice to the same event.

Reed thought he covered all the possible loopholes to ensure a correct count of attendees, until he realized that the same double agent could scan a different finger at different events, so that two or three distinct ID numbers could correspond to the same person!

For this year, Reed will settle for knowing the minimum possible number of distinct double agents who attended at least one event, given that each pair of ID numbers from the same event corresponds to distinct double agents, and that each individual ID number always corresponds to the same double agent (since no two double agents share identical fingerprints).

In the first sample case, one double agent might have attended all three events and scanned two different fingers, so that the system registered this sneaky (or clumsy) double agent with two ID numbers, 0 and 3. Since all ID numbers in the same event correspond to different double agents, three distinct double agents attended the morning event, and so at least three double agents attended at least one event in the conference.

Input

Input begins with a line consisting of three space-separated integers $1 \leq p_ m, p_ a, p_ e \leq 100\, 000$, the number of double agents who checked into the morning, afternoon, and evening events respectively. The next three lines respectively consist of $p_ m, p_ a, p_ e$ space-separated non-negative integers strictly less than $100\, 000$ and given in strictly ascending order, corresponding to the ID numbers that checked in for the three events.

Output

Output the minimum possible number of double agents who attended at least one event at the conference, given that all ID numbers from the same event correspond to distinct double agents, and that each individual ID number corresponds to the same double agent across the events.

Sample Input 1 Sample Output 1
3 2 2
0 1 2
1 3
2 3
3
Sample Input 2 Sample Output 2
9 10 10
0 2 3 7 9 11 12 13 14
1 2 3 5 6 7 8 10 12 15
0 1 3 4 5 7 9 10 11 13
11

Please log in to submit a solution to this problem

Log in