//#pragma comment(linker,"/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include #include #define ll long long #define db double #define PB push_back #define lson k<<1 #define rson k<<1|1 using namespace std; const int N = 1000005; int a[N], b[N], cnt[N]; int lb; int getint() { char c = getchar(); while(!isdigit(c)) c = getchar(); int res(c - '0'); c = getchar(); while(isdigit(c)) { res = res * 10 + c - '0'; c = getchar(); } return res; } int main() { #ifdef PKWV // freopen("in.in","r",stdin); #endif // PKWV int n, m; while(scanf("%d%d", &n, &m) + 1) { for(int i = 0; i < n; i++) a[i] = getint(); sort(a, a + n); lb = 0; b[++lb] = a[0], cnt[lb] = 1; for(int i = 1; i < n; i++) { if(a[i] != a[i - 1]) { b[++lb] = a[i]; cnt[lb] = 1; } else cnt[lb]++; } for(int i = 0; i < m; i++) { int q = getint(); int l = 1, r = lb, res(-1); while(l <= r) { int mid = (l + r) >> 1; if(b[mid] < q) l = mid + 1; else if(b[mid] > q) r = mid - 1; else { res = mid; break; } } if(res == -1) printf("0\n"); else { printf("%d\n", cnt[res]); cnt[res] = 0; } } } return 0; }