#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define gcd(a,b) __gcd(a,b)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterator
#define SET setprecision
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
#define mod1 1000000007
#define mod2 998244353
#define infmod 9223372036854775783
#define tc int t;cin>>t;while(t--)solve();
using namespace std;
int ans;
int n,k;
pii a[105],b[105];
map<int,bool>flag;
int z;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	cin>>z>>n;
	REP(i,0,n)cin>>a[i].first>>a[i].second;
	cin>>k;
	REP(i,0,k)cin>>b[i].first>>b[i].second;
	REP(i,0,1<<k){
		int x=i;
		REP(j,0,k){
			if(x%2==0)flag[b[j].first]=1;
			else flag[b[j].second]=1;
			x/=2;
		}
		int cnt=0;
		REP(j,0,n)
		if(flag[a[j].first]&&flag[a[j].second])cnt++;
		ans=max(ans,cnt);
		map<int,bool>::IT it;
		for(it=flag.begin();it!=flag.end();it++)it->second=0;
	}
	cout<<ans;
    return 0;
}

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

#define ll long long 
#define vll vector<long long>
#define f first
#define s second
#define pb push_back
#define printoneline(arr) for(long long i=0;i<arr.size();i++){cout<<arr[i]<<" ";} cout<<"\n";
#define sort(a) sort(a.begin(),a.end());
#define rsort(a) sort(a.rbegin(),a.rend());
#define reverse(a) reverse(a.begin(),a.end());
#define input(arr) for(long long i=0;i<arr.size();i++){cin>>arr[i];}


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll N,W;
    cin>>N>>W;
    cout<<(N/W)<<"\n";
    return 0;
}
