The Board

No attempts yetTime limit1sMemory limit128 MB

Problem

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?

Input

The first line contains two integers nn, mm (1n,m1061 \le n, m \le 10^6), the lengths of the sequences written by Kacper and Adi, respectively.

The second line contains Kacper's sequence as nn digits (each 0 or 1) separated by spaces.

The third line contains Adi's sequence as mm digits (each 0 or 1) separated by spaces.

Output

Print a single integer: the length of the longest sequence that can remain on the board. Print 00 if nothing can remain.