import java.io.;
import java.util.;
class Main{
private static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
private static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
public static int nextInt()throws Exception{
in.nextToken();
return (int)in.nval;
}
private static int n1, n2, m, idx, ans;
private static int[] h, e, ne, match;
private static boolean[] st;//st很重要 所有女孩在一次递归中 只看一便
public static boolean cal(int a){
for(int i=h[a];i!=-1;i=ne[i]){
int j = e[i];
if(!st[j]){
st[j] = true;//看上j女孩 占上 别人不许看
if(match[j]==0||cal(match[j])){//如果更换失败 也不改变原来的匹配结果
match[j] = a;
return true;
}
}
}
return false;
}
public static void add(int a, int b){
e[idx] = b;
ne[idx] = h[a];
h[a] = idx++;
}
public static void main(String[] args) throws Exception{
n1 = nextInt(); n2 = nextInt(); m = nextInt();
h = new int[n1+1];
e = new int[100010];
ne = new int[100010];
st = new boolean[n2+1];
match = new int[n2+1];
Arrays.fill(h, -1);
int u, v;
ans = 0;
while(m--!=0){
u = nextInt(); v = nextInt();
add(u, v);
}
for(int i=1; i<=n1; i++){
Arrays.fill(st, false);//每次都要重新尝试 上面的已匹配点 要让着下面
if(cal(i)) ans++;
}
out.print(ans);
out.close();
}
}