#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool proveri(vector<int> a, int b){
    int i = a.size()/2, c = a[i], donja = 0, gornja = a.size() - 1;
    while(b != a[i]){
        if(b == a[i]) return true;
        else if(b < a[i]) gornja = i - 1;
        else donja = i + 1;
    
        if(gronja == donja) return false;
        i = (gronja - donja)/2;
    }
}

int main() {
    int n, q, brojac = 0;
    cin >> n >> q;
    vector<int> a(n);
    vector<int> b(q);

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < q; i++){
        cin >> b[i];
    }

    sort(a.begin(), a.end());

    for(int i = 0; i < q; i++){
        int m = b[i], medijana = odredi_medijanu(a);
        if(proveri(a, m)){
            brojac++;
            a.push_back(m);
            sort(a.begin(), a.end());
        }

    }
}