Description
Problem Statement
We have an integer sequence A of length N and an integer sequence B of length M.
Takahashi will make a new sequence A′ by removing some elements (possibly zero or all) from A and concatenating the remaining elements.
Similarly, he will make another new sequence B′ by removing some elements (possibly zero or all) from B and concatenating the remaining elements.
Here, he will remove elements so that |A′|=|B′|. (|s| denotes the length of s for a sequence s.)
Let x be the total number of elements removed from A and B, and y be the number of integers ii such that 1≤i≤|A′| and A′i≠B′i. Print the minimum possible value of x+y.
Constraints
-
1≤N,M≤1000
-
1≤Ai,Bi≤109
-
All values in input are integers.
Input
Input
Input is given from Standard Input in the following format:
N M
A1 A2 A3 … AN
B1 B2 B3 … BM
Output
Output
Print the minimum possible value of x+y.
HINT
If we make A′ by removing A4 from A, and B′ by removing nothing from B, x will be 1.
Here, there is just one integer i such that 1≤i≤|A′| and A′i≠B′i i: i=2 so y will be 1, and x+y will be 2, which is the minimum possible value.