#include<iostream>
#include<cstring>
using namespace std;
const int N = 100010;
int e[N], en[N], h[N], match[N], idx; bool str[N];
void add(int a, int b)
{
e[idx] = b; en[idx] = h[a]; h[a] = idx++;
}
bool find(int u)
{
for (int i = h[u]; i != -1; i = en[i])
{
if (!str[i])
{
if (match[i] == 0 || find(match[i]))
{
str[i]=true;
match[u] = u;
return true;
}
}
}
return false;
}
int main()
{
int n1, n2,m;
memset(h, -1, sizeof h);
while (m--)
{
int a, b;
cin >> a >> b;
add(a, b);
}
int res = 0;
for (int i = 0; i != -1; i = en[i])
{
memset(str, false, sizeof str);
if (find(i))res++;
cout << res;
}
}