P28935 [洛谷] Meeting Seating
提高-
题目描述

Problem Background

It seems the principal enjoys convening full-staff meetings, forcing teachers to listen to his grandstanding.

Problem Description

The principal has published a seating chart on the school's website, where $n$ teachers are arranged from left to right in a row. The teachers are satisfied with this seating arrangement.

However, when the meeting starts, the principal accidentally shuffles the seating chart, causing dissatisfaction among the teachers. Teachers don't care about how much their own positions have changed, but if there is a pair of teachers $a$ and $b$ who originally sat with $a$ to the left of $b$ and now find $a$ to the right of $b$, this pair of teachers contributes one unit of dissatisfaction.

The principal wants to know the total dissatisfaction of the teachers.

Input Format

The first line contains a positive integer $n$, representing the number of teachers.

The second line contains $n$ strings, each representing a teacher's name (case-sensitive). This line represents the original seating chart.

The third line contains $n$ strings, representing the shuffled seating chart.

Output Format

A single line containing a positive integer, representing the total dissatisfaction of the teachers.

Sample Input and Output

Sample Input #1

3
Stan Kyle Kenny
Kyle Stan Kenny

Sample Output #1

1

Sample Input #2

5
A B C D E
B A D E C

Sample Output #2

3

Notes

For $30\%$ of the data, $1 \le n \le 10^3$.

For $100\%$ of the data, $1 \le n \le 10^5$, each teacher's name is no longer than 5 characters, consists only of uppercase and lowercase letters, and are all distinct. Note that names are case-sensitive.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 Stan Kyle Kenny Kyle Stan Kenny
样例输出
1