Electricity
문제
You are managing a power network for a programming competition and you have to connect a lot of computers to the power supply. Unfortunately, there are two standards for electrical plug and socket: A and B. These standards are incompatible, so the plug of standard A can only be plugged in the socket of standard A and the plug of standard B can only be plugged in the socket of standard B.
In the main competition hall, there is exactly one main socket of type A. Every computer that will be used in this programming competition has one plug of type A. Thereby only one computer can be connected directly to the main socket. But you have a number of power strips of two types.
- Power strips of the first type have one plug of type A and several sockets of type B.
- Power strips of the second type have one plug of type B and several sockets of type A.
All the power strips are very powerful and can withstand any load. So you can create a power network by connecting one power strip of the first type to the main socket, then some power strips of the second type to this power strip of the first type, etc. At the end you will get several available sockets of type A for computers.
Your task is to find the maximum number of computers that can be connected to the power network, using available power strips.
입력
The first line of input file contains two integer numbers n and m — the number of power strips of the first and the second type (0 ≤ n, m ≤ 100 000).
The second line contains n integer numbers ai — the number of sockets on the power strips of the first type (1 ≤ ai ≤ 1000).
The second line contains m integer numbers bi — the number of sockets on the power strips of the second type (1 ≤ bi ≤ 1000).
출력
Output the maximum number of computers that can be connected to the power network.
힌트
[이미지 1]
Possible solution for the sample.
예제
예제 1
3 2 3 2 1 2 3
5
예제 2
2 3 2 2 2 3 1
5