Winnie’s Friends#69

Winnie’s Friends

1 second
64 megabytes
Very easy

Winnie-the-Pooh decided to play an interesting game with his friends.

Winnie took some stones and arranged them in a row into heaps. Each of Winnie’s friends, in turn, would come, take the leftmost heap of stones, and distribute all the stones from this heap onto each of the following heaps, placing one stone per heap. If the number of heaps is less than the number of stones taken by the friend, the remaining stones form new heaps at the end. The process continues until the last of Winnie’s friends has taken their turn. After the game, there are heaps of stones remaining.

Consider the following example:

Initial state:

Friend #1: 6\ 2\ 4\ 7\ 1\ 1\ 1

Friend #2: 3\ 5\ 8\ 2\ 2\ 2

Friend #3:

Given the initial and final states of the heaps, determine the number of Winnie’s friends who played the game.

Input

The first line contains two integers and (2 \le M, N \le 1000): is the number of heaps in the initial state, and is the number of heaps after the game. The second line contains integers M_i (1 \le M_i \le 100), where M_i is the number of stones in the -th heap in the initial state. The third line contains integers N_i (1 \le N_i \le 100), where N_i is the number of stones in the -th heap after the game.

Output

Output a single integer — the number of Winnie’s friends.

Examples

Example 1

Loading
Loading