using System; using System.Linq; using System.Collections.Generic; class No123 { static void Main() { var num = Console.ReadLine().Split(' ').Select(x => (Int32.Parse(x))).ToArray(); var list = Enumerable.Repeat(-1, num[0]).ToList(); var index = Console.ReadLine().Split(' ').Select(x => (Int32.Parse(x))).ToArray(); var length = index.Length; for (int i = 0; i < length; ++i) { if (list[index[i]-1] == -1) list.Add(index[i]); else { var n = list[index[i]-1]; list.Remove(n); list.Add(n); } } Console.WriteLine(list.Last() != -1 ? list.Last() : 1); } }