#include "bits/stdc++.h"

using namespace std;

const int MAXN = 3e5+10;
int cores[MAXN];
int pos[51];
int n, m;

int solve(int cor){
    int ans = pos[cor];
    for(int i = 1; i <= 50; i++){
        if(pos[i] < pos[cor] && pos[i]) pos[i]++;
    }
    pos[cor] = 1;
    return ans;
}

int main(){

    cin>>n>>m;

    for(int i = 0; i < n; i++){
        cin>>cores[i];
        if(!pos[cores[i]]) pos[cores[i]] = i+1;
    }

    for(int i = 0; i < m; i++){
        int query;
        cin>>query;
        cout<<solve(query)<<'\n';
    }
    return 0;
}