using System;
using System.Collections.Generic;
using System.Linq;
namespace zad
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]), q = int.Parse(s[1]);
            List<int> a = new List<int>(); List<int>b=new List<int>();
            s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++) a.Add(int.Parse(s[i]));
            s = Console.ReadLine().Split();
            for (int i = 0; i < q; i++) b.Add(int.Parse(s[i]));
            var a1=a.ToArray();
            for (int i = 0; i < q; i++)
            {
               int br = 0;
                if (a.Contains(b[i]))
                { a.Sort(); br += Math.Abs(a.IndexOf(b[i]) + (a.IndexOf(b[i]) - n / 2) - n / 2); if (a.IndexOf(b[i]) > n / 2) br--; }
                else { a.Add(b[i]); a.Sort(); br += Math.Abs(a.IndexOf(b[i]) + a.IndexOf(b[i]) - a.Count / 2+1 - a.Count / 2); if (Math.Abs(a.IndexOf(b[i]) - a.Count() / 2) == 1) br--; }
               Console.WriteLine(br);
               a = new List<int>(a1);
            } 
            }
        }
    }