TLE..
var
i,j,k,l,m,n,x,y,Ans:longint;
a:array[1..2000,1..2000]of boolean;
v:array[1001..2000]of boolean;
opp:array[1..2000]of longint;
function find(x:longint):boolean;
var
i:longint;
begin
for i:=1001to 1000+m do begin
if (not v[i])and(a[x][i])
then begin
v[i]:=true;
if (opp[i]=0)or(find(opp[i]))
then begin
opp[i]:=x;exit(true);
end;
end;
end;
exit(false);
end;
begin
readln(n,m,x);Ans:=0;
for i:=1to x do begin
readln(j,k);
a[j][k+1000]:=true;//a[k+n][j]:=false;
end;
for i:=1to n do begin
fillchar(v,sizeof(v),false);
if find(i)then inc(Ans);
end;
writeln(n+m-Ans);
end.