#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	vector<int>B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	int K;
	cin >> K;
	vector<int>C(K);
	vector<int>D(K);
	rep(i, K) {
		cin >> C[i] >> D[i];
		C[i]--;
		D[i]--;
	}
	int ans = 0;
	rep(i, (1 << K)) {
		vector < bool >Tama(N);
		rep(j, K) {
			if (1&(i >> j)) {
				Tama[C[j]] = true;
			}
			else {
				Tama[D[j]] = true;
			}
		}
		int anssub = 0;
		//rep(j, N) {
		//	cout << Tama[j] << "_";
		//}
		//cout << endl;
		rep(j, M) {
			if ((Tama[A[j]]) && (Tama[B[j]])) {
				anssub++;
			}
		}
		ans = max(ans, anssub);
	}
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string a,b;
    cin >> a >> b;
    ll as = 0;
    ll bs = 0;
    for(int i = 0;i < (int)a.size();i++)as += a[i] - '0';
    for(int i  =0;i < (int)b.size();i++)bs += b[i] - '0';
    cout << max(as,bs) << endl;
}