#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	map<string, bool> memo;
	string s;
	int n, m;
	cin >> n;
	rep(i, n){
		cin >> s;
		memo[s] = 1;
	}
	cin >> m;
	int cnt = 0;
	rep(i, m){
		cin >> s;
		if(memo[s])cnt++;
	}
	FIN(cnt);

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<pii> s(n),l(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        s[i] = make_pair(b,a);
    }
    rep(i,n){
        int c,d;
        cin >> c >> d;
        l[i] = make_pair(c,d);
    }
    sort(l.begin(),l.end());
    int ans = 0;
    rep(i,n){
        sort(s.rbegin(),s.rend());
        rep(j,s.size()){
            if(s[j].second < l[i].first && s[j].first < l[i].second){
                ans++;
                s.erase(s.begin() + j);
                break;
            }
        }
    }
    cout << ans << endl;
}
