#include<bits/stdc++.h>
using namespace std;
const int maxn=550;
int n,m,k;
int pot[maxn],vis[maxn][maxn],w[maxn][maxn];
template<class type> const void read(type &in)
{
in = 0;
char ch = getchar();
while(ch < 48 || ch > 57)ch = getchar();
while(ch > 47 && ch < 58)
{
in = (in << 1) + (in << 3) + (ch & 15);
ch =getchar();
}
return;
}
void reset()
{
memset(pot,0,sizeof(pot));
memset(w,0,sizeof(w));
}
void in()
{
read(n),read(m),read(k);
for(int i=1; i<=k ;i++)
{
int a,b;
read(a),read(b);
w[a][b]=1;
}
}
bool Xlie(int u)
{
for(int i=1; i<=m ;i++)
{
if(w[u][i]&&!vis[u][i])
{
vis[u][i]=1;
if(!pot[i]||Xlie(i))
{
pot[i]=u;
return true;
}
}
}
return false;
}
void out()
{
int sum=0;
for(int i=1; i<=n ;i++)
{
memset(vis,0,sizeof(vis));
if(Xlie(i))sum++;
}
cout<<sum;
}
int main()
{
reset();
in();
out();
}