#include<stdio.h>
#include<string.h>
bool map[509][509];
int mark[509];
bool flag[509];
int m;
char A[509][9];
char B[509][9];
bool dfs(int x)
{
int i;
for(i=1;i<=m;i++)
{
if(map[x][i]==0||flag[i]) continue;
flag[i]=1;
if(mark[i]==0||dfs(mark[i]))
{
mark[i]=x;
return 1;
}
}
return 0;
}
int main()
{
int i,g,k,j;
int count;
while(scanf("%*d%*d%d",&k)!=EOF)
{
g=m=k;
memset(map,0,sizeof(map));
memset(mark,0,sizeof(mark));
count=0;
for(i=1;i<=k;i++)
{
scanf("%s",A[i]);
scanf("%s",B[i]);
}
for(i=1;i<=k;i++)
{
for(j=1;j<=k;j++)
{
if(strcmp(A[i],B[j])==0)
{
map[i][j]=1;
// map[j][i]=1;
}
}
}
for(i=1;i<=g;i++)
{
memset(flag,0,sizeof(flag));
if(dfs(i)==1) count++;
}
printf("%d\n",k-count/2);
}
}