#include <iostream>
#include <unordered_set>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int dem = 0;
unordered_set <int> l1;
for(int i = 0 ; i < N; i++){
int A;
cin >> A;
l1.insert(A);
}
for(int i = 0 ; i < M ; i++){
int B;
cin >> B;
if(l1.count(B)){
dem++;
}
}
cout << dem << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dW5vcmRlcmVkX3NldD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJaW50IE4sIE07CgljaW4gPj4gTiA+PiBNOwoJaW50IGRlbSA9IDA7Cgl1bm9yZGVyZWRfc2V0IDxpbnQ+IGwxOwoJCglmb3IoaW50IGkgPSAwIDsgaSA8IE47IGkrKyl7CgkJaW50IEE7CgkJY2luID4+IEE7CgkJbDEuaW5zZXJ0KEEpOwoJfQoJCglmb3IoaW50IGkgPSAwIDsgaSA8IE0gOyBpKyspewoJCWludCBCOwoJCWNpbiA+PiBCOwoJCWlmKGwxLmNvdW50KEIpKXsKCQkJZGVtKys7CgkJfQoJfQoJY291dCA8PCBkZW0gPDwgZW5kbDsKCQp9