#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
inline constexpr bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
inline constexpr bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <typename T>
struct SkipList{

    static uint32_t rnd(){
        static uint32_t x = 123456789, y = 362436069, z = 521288629, w = time(0);
        uint32_t t = x ^ (x << 11);
        x = y, y = z, z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w;
    }

    struct Node{
        int height;
        T key;
        vector<Node*> next, prev;
        Node(T key, int height) : key(key), height(height), next(height, nullptr), prev(height, nullptr){}
    };

    using NodePtr = Node*;
    int max_height;
    int size;
    NodePtr root;

    SkipList() : max_height(0), size(0){
        root = new Node(T(), 32);
    }

    void insert(T key){

        ++size;
        int cnt = 0;

        uint32_t r = max(rnd(), uint32_t(1));
        int height = __builtin_ffs(r);
        if(max_height < height)
            max_height = height;
        NodePtr node = new Node(key, height);
        NodePtr pre = root;
        for(int i = max_height - 1; i >= 0; --i){
            for(; i < pre->next.size() && pre->next[i] != nullptr && pre->next[i]->key < key; pre = pre->next[i])
                ++cnt;
            if(i < height){
                NodePtr nex = pre->next[i];
                pre->next[i] = node;
                node->prev[i] = pre;
                if(nex != nullptr){
                    nex->prev[i] = node;
                    node->next[i] = nex;
                }
                assert(pre->key <= key && (nex == nullptr || key <= nex->key));
            }
        }
    }

    void erase(T key){
        --size;
        vector<NodePtr> prev_vec(max_height);
        NodePtr pre = root;
        for(int i = max_height - 1; i >= 0; --i){
            for(; i < pre->next.size() && pre->next[i] != nullptr && pre->next[i]->key < key; pre = pre->next[i]);
            prev_vec[i] = pre;
        }
        if(pre->next[0] == nullptr || pre->next[0]->key != key)
            return;
        // メモリ解放はしない(してもいいけど)
        NodePtr target = pre->next[0];
        for(int i = 0; i < max_height; ++i){
            pre = prev_vec[i];
            NodePtr nex = pre->next[i];
            if(nex == target)
                nex = nex->next[i];
            pre->next[i] = nex;
            if(nex != nullptr)
                nex->prev[i] = pre;
        }
    }

    NodePtr lower_bound(T key){
        NodePtr pre = root;
        for(int i = max_height - 1; i >= 0; --i)
            for(; i < pre->next.size() && pre->next[i] != nullptr && pre->next[i]->key < key; pre = pre->next[i]);
        return pre->next[0];
    }

    NodePtr upper_bound(T key){
        NodePtr pre = root;
        for(int i = max_height - 1; i >= 0; --i)
            for(; i < pre->next.size() && pre->next[i] != nullptr && pre->next[i]->key <= key; pre = pre->next[i]);
        return pre->next[0];
    }

    bool contains(T key){
        NodePtr ptr = lower_bound(key);
        return ptr != nullptr && ptr->key == key;
    }

    void print(){
        for(NodePtr node = root->next[0]; node != nullptr; node = node->next[0]){
            cout << node->key << " ";
        }
        cout << endl;
    }
};


signed main(){
    SkipList<int> slist;
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; ++i)
        cin >> s[i];
    int q;
    cin >> q;
    vector<int> t(q);
    for(int i = 0; i < q; ++i)
        cin >> t[i];
    for(auto x : s)
        slist.insert(x);
    int cnt = 0;
    for(auto y : t)
        cnt += slist.contains(y);
    cout << cnt << endl;
}


Measured memory_bytes: 16488