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

    int N, Q, i, j, q, t, ans, l, r, mid;
    bool found;
    cin >> N >> Q;
    int a[N], b[Q];
    for(i=0;i<N;++i)
        cin >> a[i];
    for(i=0;i<Q;++i)
        cin >> b[i];

    t = N/2;
    for(j=0;j<Q;++j)
    {
        q = b[j];
        found = false;
        for(i=0;i<N;++i)
        {
            if(a[i]==q && !found)
            {
                ans = abs(i-t);
                found = true;
            }
        }
        if(!found)
            ans = N;
        cout << ans << endl;
    }


}