// I may fail a thousand times
// But there is no giving up
// IOI - here I come
#include <bits/stdc++.h>
using namespace std;
const int N=2e5;
int a[N+5],b[N+5];
map<int,int> c;
void solve(){
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i],c[a[i]]++;
	for(int i=1;i<=m;i++)cin>>b[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=m;i++){
		int res=0;
		int l=0;
		int lo=1,hi=n;
		for(;lo<=hi;){
			int mi=(lo+hi)>>1;
			if(a[mi]<b[i]){
				l=mi;
				lo=mi+1;
			}else hi=mi-1;
		}
		lo=0,hi=n+5;
		if(c[b[i]]==0)lo=1;
		for(;lo<=hi;){
			int mi=(lo+hi)>>1;
			int pos=(mi+n)/2+1;
			int r=l+1+c[b[i]]+mi-1;
			if(pos<=r&&pos>l){
				res=mi;
				hi=mi-1;
			}else{
				lo=mi+1;
			}
		}
		cout<<res<<'\n';
	}
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	for(;t;t--){
		solve();
	}
	return 0;
}