C. LCS on Permutations
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given two permutations $$$a$$$ and $$$b$$$ of length $$$N$$$ ($$$1 \leq N \leq 10^5$$$). Determine the length of their longest common subsequence.

Input

Line 1: The single integer $$$N$$$

Line 2: $$$N$$$ space separated integers $$$a_1 \dots a_N$$$ ($$$1 \leq a_i \leq N$$$ and $$$a_i \neq a_j$$$ for all $$$1 \leq i < j \leq N$$$)

Line 3: $$$N$$$ space separated integers $$$b_1 \dots b_N$$$ ($$$1 \leq b_i \leq N$$$ and $$$b_i \neq b_j$$$ for all $$$1 \leq i < j \leq N$$$)

Output

A single integer: the answer to the above problem

Example
Input
5
3 2 1 4 5
1 2 3 4 5
Output
3
Note

One possible longest common subsequence would be $$$3, 4, 5$$$.