#include<bits/stdc++.h>
using namespace std;
const int Maxn=1e6+5;
const int mod=1e9+7;
const int inf=0x7fffffff;
#define reg register
typedef long long ll;
typedef unsigned long long ull;
namespace io{
const int _SIZE=(1<<21)+1;
char *iS,*iT,ibuf[_SIZE],c,stk[40];int tot;
#define gc()(iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,_SIZE,stdin),(iS==iT?EOF:*iS++)):*iS++)
template<class I>
inline void read(I &_x){
I fl=1;
for(c=gc();c<'0'||c>'9';c=gc()) if(c=='-') fl=-1;
for(_x=0;c<='9'&&c>='0';c=gc()) _x=(_x<<3)+(_x<<1)+(c&15);
_x*=fl;
}
template<class I>
inline void prt(I _x,char ch='\0'){
tot=0;
if(_x<0) putchar('-'),_x*=-1;
do{
stk[++tot]=_x%10|48,_x/=10;
}while(_x);
do{
putchar(stk[tot--]);
}while(tot);
if(ch) putchar(ch);
}
}
using io::read;
using io::prt;
int n,m1,m2;
struct line{
int l,r;
}e1[Maxn],e2[Maxn];
int cnt1[Maxn],cnt2[Maxn],tot1,tot2;
int ans1[Maxn],ans2[Maxn];
ll ans;
inline void solve(){
for(reg int i=1;i<=m1;i++){
if(tot1==0){
cnt1[++tot1]=i,ans1[tot1]++;
continue;
}
for(reg int j=1;j<=tot1;j++){
if(e1[i].l<e1[cnt1[j]].r){
if(j==tot1){
cnt1[++tot1]=i,ans1[tot1]++;
break;
}
else continue;
}
else{
cnt1[j]=i;
ans1[j]++;
break;
}
}
}
for(reg int i=1;i<=m2;i++){
if(tot2==0){
cnt2[++tot2]=i;ans2[tot2]++;
continue;
}
for(reg int j=1;j<=tot2;j++){
if(e2[i].l<e2[cnt2[j]].r){
if(j==tot2){
cnt2[++tot2]=i,ans2[tot2]++;
break;
}
else continue;
}
else{
cnt2[j]=i;
ans2[j]++;
break;
}
}
}
}
void print(){
for(int i=1;i<=tot1;i++) prt(i,':'),prt(ans1[i],' ');
puts("");
for(int i=1;i<=tot2;i++) prt(i,':'),prt(ans2[i],' ');
}
#define fname "airport"
int main(){
read(n),read(m1),read(m2);
for(reg int i=1;i<=m1;i++) read(e1[i].l),read(e1[i].r);
for(reg int i=1;i<=m2;i++) read(e2[i].l),read(e2[i].r);
solve();
for(reg int i=1;i<=tot1;i++) ans1[i]+=ans1[i-1];
for(reg int i=1;i<=tot2;i++) ans2[i]+=ans2[i-1];
for(reg int i=1;i<=n;i++){
ans=max(ans,1ll*(ans1[i]+ans2[n-i]));
}
prt(ans);
return 0;
}