You are given two sequences, a and b, of lengths n and m respectively. Your task is to find the length of the longest common subsequence of the two sequences.
💡
A subsequence is a new sequence obtained by deleting some (or none) of the elements of the original sequence, without changing the order of the remaining elements.
Input
The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 1000).
The second line contains n space-separated integers , representing the elements of sequence a (1 ≤ ≤ ).
The third line contains m space-separated integers , representing the elements of sequence b (1 ≤ ≤ ).
Output
Print a single integer - the length of the longest common subsequence of a and b.