#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define fi "BRIDGE.INP"
#define fo "BRIDGE.OUT"
int m,n,k;
int c[101][3];
int f[1001][1001];
bool a[1001][1001];

void Enter()
{
	int i,j;
	cin>>m>>n>>k;
	for (int i=1;i<=k;i++)
		cin>>c[i][1]>>c[i][2];
	memset(a,0,sizeof(a));
	while (true)
	{
		cin>>i>>j;
		if (i==0)
			break;
		a[i][j]=1;
	}
}

bool check(int i, int j)
{
	for (int t=1;t<=k;t++)
		if (c[t][1]==i or c[t][2]==j)
			return false;
		else
			if (c[t][1]<i and c[t][2]>j)
				return false;
			else
				if (c[t][1]>i and c[t][2]<j)
					return false;
	return true;
}

void Optimize()
{
	memset(f,0,sizeof(f));
	for (int i=1;i<=m;i++)
		for (int j=1;j<=n;j++)
			if (a[i][j]==0 or !check(i,j))
				f[i][j]=max(f[i-1][j],max(f[i][j-1],f[i-1][j-1]));
			else
				f[i][j]=max(f[i-1][j],max(f[i][j-1],f[i-1][j-1]+1));
}

void PrintResult()
{
	cout<<f[m][n]<<"\n";
}

int main()
{
	freopen(fi,"r",stdin);
	freopen(fo,"w",stdout);
	Enter();
	Optimize();
	PrintResult();
	return 0;
}
