#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)

//CUSTOM
#define L(x) (sizeof(x) / sizeof(*x))

using namespace std;

using namespace __gnu_pbds;

int main()
{

    FAST;

    int n, q; cin >> n >> q;
    int A[n], B[q];
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = 0; i < q; i++) cin >> B[i];

    //Sort
    int len = L(A);
    sort(A, A + len);

    int medianIndex = (len/2);

    for(int i = 0; i < q; i++){
        int e = 0;
        // -5 Index of s nuber in A[]
        int indexS = -5;
        for(int j = 0; j < n; j++){
            if(A[j] == B[i]){
                indexS = j;
                break;
            }
        }


        if(indexS >=0){
            if(medianIndex <= indexS){
                e = indexS - medianIndex;
                if(e % 2 == 0) e = e * 2;
                else e = (e * 2) - 1;
            }
        }


        cout << e << endl;
    }

    return 0;
}