//meek///#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std ;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define MP make_pair
typedef long long ll;
const int N = 100005;
const int inf = 99999999;
const int mod= 1000000007;
int y[N],lk[N],x,n,m;
vector<int >G[N*2];
int dfs(int v) {
for(int i=0;i<G[v].size();i++) {
if(!y[G[v][i]]) {
y[G[v][i]]=1;
if(lk[G[v][i]]==0||dfs(lk[G[v][i]])) {
lk[G[v][i]]=v;
return 1;
}
}
}
return 0;
}
int solve() {
int ans=0;
for(int i=1;i<=n;i++) {
mem(y) ;
if(dfs(i)) ans+=1;
else return ans;
}
return ans;
}
int main() {
int y;
scanf("%d%d",&m,&n);
for(int i=1;i<=n;i++) {
scanf("%d%d",&x,&y);
G[i].pb(x+n);
G[i].pb(y+n);
}
printf("%d\n",solve());
return 0;
}