using System; using static System.Console; using static System.Math; using System.Numerics; using System.Collections.Generic; using System.Linq; namespace AtCoder { public class Program { public static void Main(string[] args) { var n = int.Parse(ReadLine()); //var s = Conasole.ReadLine().Split(' ') var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var ans = 0; for (int i = 0; i < n; i++) { int b_value = b[i]; int a_num = Array.IndexOf(a, b_value); ans += a_num - i; a = Swap(a, i, a_num); } WriteLine(ans); Out.Flush(); } public static int[] Swap(int[] a, int n, int m) { if (n == m) return a; else { int i = a[m]; for (int j = m; j > n; j--) { a[j] = a[j - 1]; } a[n] = i; } return a; } } }