#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,M,L;
    int Open = 0;
    cin>>N>>M;
    vector<int> A,B;
    for(int i=0; i<N; i++){
        cin>>L;
        A.push_back(L);
    }
    for(int i=0; i<M; i++){
        cin>>L;
        B.push_back(L);
    }
    sort(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());
    M = B.size();
    for(int i=0; i<M; i++){
        for(int l=0; l<N; l++){
            if(A[l]==B[i]){
                Open++;
            }
        }
    }
    cout<<Open;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: