#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define F first
#define S second
using namespace std;
typedef long long ll;
//const int maxn = ;

int cnt[53];

int main()
{
	fast;
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
		
	for (int i = n - 1; i >= 0; i--)
		cnt[a[i]] = i + 1;
	
	vector<pair<int, int> > b;
	for (int i = 1; i <= 50; i++)
		if (cnt[i])
			b.push_back({cnt[i], i});
	
	for (int i = 0; i < q; i++)
	{
		sort(b.begin(), b.end());
		int in;
		cin >> in;
		for (int i = 0; i < b.size(); i++)
		{
			if (b[i].second == in)
			{
				cout << b[i].first << ' ';
				b[i].first = 1;	
				break;
			}	
			else
				b[i].first++;
		}	
		
	}	
}

