#include <iostream>
#include <vector>
using namespace std;
int bp(vector<int>a, int x)
{
	int l = 0, d = a.size() - 1;
	while (l<=d)
	{
		int s = (l + d) / 2;
		if (a[s] >= x) d = s - 1;
		else l = s + 1;
	}
	return l;
}
int main()
{
	int n, q; cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < q; i++)
	{
		int b; cin >> b;
		int pre = bp(a, b);
		int posle = n - pre;
		bool p = pre < n && a[pre] == b;
		if (p) posle--;
		if (posle > pre) {
			if (p) cout << posle - pre;
			else cout << posle - pre + 1;
			cout << endl;
		}
		else if (posle == pre) {
			if (p) cout << 0;
			else cout << 1;
			cout << endl;
		}
		else {
			if (p) cout << pre - posle - 1;
			else cout << pre - posle;
			cout << endl;
		}
	}
}