#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n, queries;
	cin>>n>>queries;
	
	unordered_map<int, int> freq;
	int arr[n];
	for(int i=0; i < n; i++){
		cin>>arr[i];
	}
	
	for(int i = 0; i < n; i++){
		freq[arr[i]]++;
	}
	
	for(int i = 0; i < queries; i++){
		int query;
		cin>> query;
		
		cout<<freq[query]<<endl;
	}
	return 0;
}