#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int MAXN(201);
int n, n1, u, v, tim = 0, ans = 0, used[MAXN], girl[MAXN];
bool find(int), a[MAXN][MAXN] = {false};
ifstream fin("flyer.in");
ofstream fout("flyer.out");
//#define fin cin
//#define fout cout
main()
{
fin >> n >> n1;
while (fin >> u >> v)
a[u][v] = true;
for (int i = 1; i <= n1; ++i){
tim ++;
if (find(i))
ans ++;
}
fout << ans << endl;
// system("pause");
}
bool find(int x)
{
for (int i = 1; i <= n; ++i)
if (a[x][i])
if (used[i] != tim){
used[i] = tim;
if (girl[i] == 0 || find(girl[i])){
girl[i] = x;
return true;
}
}
return false;
}