Double Deck
면접 대비시간 제한2초메모리 제한1024 MB
각 deck에 1부터 N까지의 카드가 K장씩 있다. 두 deck의 맨 위 카드가 같으면 두 장을 가져가 1점을 얻고, 다르면 한 장을 버린다. 얻을 수 있는 최대 점수를 구한다.
문제
You are playing a new card game. In the game you have two decks of cards each consisting of cards labeled with an integer from to , inclusive. Also, each type of card appears precisely times in each deck.
The rules of the game are simple. You shuffle both decks and place them face up in front of you, so at each point in time you see the top card in each deck. If the top cards are the same you can take them both and get one point. Otherwise you must discard either card. Your goal is to get as many points as possible.
You have just finished playing a round of this game and you want to know what the maximum score was, knowing the layout of both decks.
입력
The first line of the input contains two integers and (). The second and third line of the input each contain integers (), describing the layout of the decks. The first number is the topmost card in the deck, is the second, and so on.
No integer in the second line and third line is repeated more than times per line.
출력
Print a single integer, the maximum possible score.