Loading [MathJax]/jax/output/CommonHTML/jax.js


Single Flip

Description

Given two permutations A and B of length N. You have to select an index x (1xN) and swap the values of Ax and Bx. 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

  • 1N100
  • 1AiN
  • 1BiN
  • 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