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 list = new List(a); var ans = 0; for (int i = 0; i < n; i++) { ans += list.IndexOf(b[i]); list.Remove(b[i]); } WriteLine(ans); Out.Flush(); } } }