#include <bits/stdc++.h>

using namespace std;
int main() {
    int n, q, resenje;
    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];
    }

    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (b[i] == a[j]){
                if ((n % 2 == 0) && (j == (n / 2) || j == (n / 2) + 1)) {
                    resenje = 0;
                }

                else {
                    resenje = n - j;
                }
            }

            else {
                resenje = n;
            }
        }
        cout << resenje << endl;
    }

    return 0;
}