Problem: Nauuo is a girl who loves playing cards.
One day she was playing cards but found that the cards were mixed with some empty ones.
There are cards numbered from to , and they were mixed with another empty cards. She piled up the cards and drew of them. The cards in Nauuo's hands are given. The remaining cards in the pile are also given in the order from top to bottom.
In one operation she can choose a card in her hands and play it — put it at the bottom of the pile, then draw the top card from the pile.
Nauuo wants to make the numbered cards piled up in increasing order (the -th card in the pile from top to bottom is the card ) as quickly as possible. Can you tell her the minimum number of operations?
Input Format: The first line contains a single integer () — the number of numbered cards.
The second line contains integers () — the initial cards in Nauuo's hands. represents an empty card.
The third line contains integers () — the initial cards in the pile, given in order from top to bottom. represents an empty card.
It is guaranteed that each number from to appears exactly once, either in or .
Output Format: The output contains a single integer — the minimum number of operations to make the numbered cards piled up in increasing order.
Note: Example 1
We can play the card and draw the card in the first operation. After that, we have in hands and the cards in the pile are from top to bottom.
Then, we play the card in the second operation. The cards in the pile are , in which the cards are piled up in increasing order.
Example 2
Play an empty card and draw the card , then play , , in order.