Single Flip

Description

Given two permutations \(A\) and \(B\) of length \(N\). You have to select an index \(x\) (\(1 \le x \le N\)) and swap the values of \(A_x\) and \(B_x\). Count the number of indices \(x\) that allows \(A\) and \(B\) to remain as permutations after swapping the index.

Note: A permutation of length \(N\) is a sequence of \(N\) integers from \(1\) to \(N\) such that each element appears exactly once in the sequence.

Constraints

  • \(1 \le N \le 100\)
  • \(1 \le A_i \le N\)
  • \(1 \le B_i \le N\)
  • \(A\) and \(B\) are permutations.

Input

N
A1 A2 … AN
B1 B2 … BN

Output

A single integer representing the number of indices such that \(A\) and \(B\) remain as permutations after swapping.

Sample Input

5
1 2 3 4 5
5 2 3 1 4

Sample Output

2

Explanation

We can select indices \(2\) or \(3\), and both \(A\) and \(B\) will remain as permutations after swapping.



Submitting .cpp to 'Single Flip'


You're not logged in! Click here to login

Time Limit: 1 Seconds
Memory Limit: 1024MB
Your best score: 0
Source: TROC 24 (maomao90)

Subtask Score
1 100