#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define N 1010
using namespace std;
typedef long long llg;
int n,m,pip[N],vis[N],cnt;
int head[N],next[N<<1],to[N<<1],tt;
int getint(){
int w=0;bool q=0;
char c=getchar();
while((c>‘9‘||c<‘0‘)&&c!=‘-‘) c=getchar();
if(c==‘-‘) c=getchar(),q=1;
while(c>=‘0‘&&c<=‘9‘) w=w*10+c-‘0‘,c=getchar();
return q?-w:w;
}
void link(int x,int y){to[++tt]=y;next[tt]=head[x];head[x]=tt;}
bool dfs(int u){
for(int i=head[u],v;i;i=next[i])
if(vis[to[i]]!=cnt){
v=to[i]; vis[v]=cnt;
if(!pip[v] || dfs(pip[v])){
pip[v]=u; return 1;
}
}
return 0;
}
int main(){
File("a");
n=getint(); m=getint();
for(int i=1;i<=m;i++)
link(i,getint()),link(i,getint());
for(int i=1;i<=m;i++){
cnt++;
if(!dfs(i)){
printf("%d",i-1);
return 0;
}
}
printf("%d",m);
}