시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 9 6 6 66.667%

문제

Emma and Marcos are two friends who love horror films. This year, and possibly the years hereafter, they want to watch as many films together as possible. Unfortunately, they do not exactly have the same taste in films. So, inevitably, every now and then either Emma or Marcos has to watch a film she or he dislikes. When neither of them likes a film, they will not watch it. To make things fair they thought of the following rule: They can not watch two films in a row which are disliked by the same person. In other words, if one of them does not like the current film, then they are reassured they will like the next one. They open the TV guide and mark their preferred films. They only receive one channel which shows one film per day. Luckily, the TV guide has already been determined for the next 1 million days.

Can you determine the maximal number of films they can watch in a fair way?

입력

The input consists of two lines, one for each person. Each of these lines is of the following form:

  • One integer 0 ≤ k ≤ 1000000 for the number of films this person likes;
  • followed by k integers indicating all days (numbered by 0, . . . , 999999) with a film this person likes.

출력

Output a single line containing a single integer, the maximal number of films they can watch together in a fair way.

예제 입력 1

1 40
2 37 42

예제 출력 1

3

예제 입력 2

1 1
3 1 3 2

예제 출력 2

2

예제 입력 3

1 2
1 2

예제 출력 3

1

힌트