#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
long long n,m1,m2,mans=-1;
struct hb{
long long arr,lef;
bool operator<(hb a)const{
return a.lef<lef;
}
}hb1s[100005],hb2s[100005];
bool cmp(hb hb1,hb hb2){
return hb1.arr<hb2.arr;
}
priority_queue<hb> a,b;
int main(){
scanf("%lld%lld%lld",&n,&m1,&m2);
for (int i=1;i<=m1;i++){
scanf("%lld%lld",&hb1s[i].arr,&hb1s[i].lef);
}
for (int i=1;i<=m2;i++){
scanf("%lld%lld",&hb2s[i].arr,&hb2s[i].lef);
}
sort(hb1s+1,hb1s+1+m1,cmp);
sort(hb2s+1,hb2s+1+m1,cmp);
for (int i=0;i<=n;i++){
long long li=i,lj=n-i,ans=0;
for (int k=1;k<=m1;k++){
while (!a.empty()&&hb1s[k].arr>a.top().lef){
a.pop();
li++;
}
if (li>0){
a.push(hb1s[k]);
ans++;
li--;
}
}
for (int k=1;k<=m2;k++){
while (!b.empty()&&hb2s[k].arr>b.top().lef){
b.pop();
lj++;
}
if (lj>0){
b.push(hb2s[k]);
ans++;
lj--;
}
}
mans=max(ans,mans);
}
printf("%lld",mans);
return 0;
}