#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// trebalo bi da prodje tle, mzd ima neko bolje resenje though
ll ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    vector<int> v;
    vector<int> ::iterator it;
    int n, q, pos, i, x;
    cin >> n >> q;
    int b[10000];
    ll mid = n/2;
    for(i=0;i<n;++i) {
        cin >> x;
        v.push_back(x);
    }
    for(i=0;i<q;++i) {
        cin >> b[i];
    }

    for(i=0;i<q;++i)
    {
        it = find(v.begin(), v.end(), b[i]);
        if(it!=v.end())
        {
            pos = it - v.begin();
            ans = abs(pos - mid);
        }
        else
        {
            ans = n;
        }
        cout << ans << endl;
    }
    return 0;
}