Kacper and Adi have grown very fond of the binary system. Each of them wrote a sequence of zeros and ones on the board. Kacper now wants to cross out some digits in each sequence so that the two remaining sequences are identical and, at the same time, sorted. Sorted means that after the first occurrence of a one, no zero may appear. What is the length of the longest sequence that can remain on the board?
The first line contains two integers n, m (1≤n,m≤106), the lengths of the sequences written by Kacper and Adi, respectively.
The second line contains Kacper's sequence as n digits (each 0 or 1) separated by spaces.
The third line contains Adi's sequence as m digits (each 0 or 1) separated by spaces.
Print a single integer: the length of the longest sequence that can remain on the board. Print 0 if nothing can remain.