As a child, Larry always played War with his friends. If you are not aware, War is a card game with simple rules. This version may be different from a version you have played.
Each player flips over the first card in their hand.
Whichever player has the higher card takes all the cards on the table into their winnings (not their hand).
However, if both revealed cards are the same… they remain on the table.
Repeat until either player has no cards left in their hand.
If there are cards left on the table, they are left.
The person with the most cards in their winnings wins, or it is a tie if they are equal.
However, Larry is a fan of violence, and doesn't particularly care who wins. Because of this, he wants to know how much war will occur in his game. Whenever the two players' cards are the same, a battle begins, which ends when the cards are won by someone.
Given some sequence of cards for Larry and his opponents decks, can you tell Larry how many battles will occur?
The first line contains an integer ~N\ (1 \leq N \leq 1000)~, the amount of cards in each hand.
The next line will contain ~N~ integers ~a_i\ (1 \leq a_i \leq 11)~, the values of the cards in Larry's hand from start to end.
The final line will contain ~N~ integers ~b_i\ (1 \leq b_i \leq 11)~, the values of the cards in Larry's opponent's hand from start to end.
You are to print one line, the number of battles that occurred.
5 1 1 2 4 3 1 2 2 4 1