#include <bits/stdc++.h>
using namespace std;

int binarySearch(vector <int> arr, int a, int b, int x){

    if(a<=b){
        int mid = (a+b)/2;
        if(x == arr[mid]){
            return mid;
        }
        if(x > arr[mid]){
            return binarySearch(arr, mid+1, b, x);
        }
        if(x < arr[mid]){
            return binarySearch(arr, a, mid-1, x);
        }

    }
    return -1;
}

int main(){

    int n;
    int q;
    cin>>n>>q;
    int a_unsorted[n];
    int b[q];
    vector <int> a;

    for(int i = 0; i<=n-1; i++){
        cin>>a_unsorted[i];
    }

    for(int i = 0; i<=n-1; i++){
        a.push_back(a_unsorted[i]);
    }

    sort(a.begin(), a.end());

    for(int i = 0; i<=q-1; i++){
        cin>>b[i];
    }

    for(int i = 0; i<=q-1; i++){

        int check;
        check = binarySearch(a, 0, a.size()-1, b[i]);

        if(check != -1){

            int left = check;
            int right = n-check-1;

            if(left == right){
                cout<<0<<endl;
            }
            if(left > right){
                while(a[check-1] == b[i]){
                    check-=1;
                    left = check;
                    right = n-check-1;
                    if(left == right){
                        cout<<0<<endl;
                        break;
                    }
                    //cout<<"proslo je"<<endl;
                }
                if(left < right){
                    cout<<0<<endl;

                }
                if(left > right){
                    cout<<left-right-1<<endl;
                }
            }
            if(left < right){
                while(a[check+1] == b[i]){
                    check+=1;
                    left = check;
                    right = n-check-1;
                    if(left == right){
                        cout<<0<<endl;
                        break;
                    }
                }
                if(left < right){
                    cout<<right-left<<endl;

                }
                if(left > right){
                    cout<<0<<endl;
                }

            }
        }

        if(check == -1){

            a.push_back(b[i]);
            sort(a.begin(), a.end());

            //cout<<"a je: ";
            //for(int t = 0; t<=a.size()-1; t++){
                //cout<<a[t]<<" ";
            //}
            //cout<<endl;

            check = binarySearch(a, 0, a.size()-1, b[i]);

            int left = check;
            int right = n+1-check-1;
            //cout<<"LEVO: "<<left<<endl;
            if(left == right){
                cout<<1<<endl;
            }
            if(left > right){

                cout<<left-right<<endl;
            }
            if(left < right){

                cout<<right-left + 1<<endl;
            }

            vector<int>::iterator it;
            it = a.begin()+check;
            a.erase(it);
        }

    }
}