1 /**************************************************************
 2     Problem: 1191
 3     User: shadowland
 4     Language: C++
 5     Result: Accepted
 6     Time:40 ms
 7     Memory:1692 kb
 8 ****************************************************************/
 9  
10 #include "bits/stdc++.h"
11  
12 using namespace std ;
13 const int maxN = 10100 ;
14 struct Match {int to , next ;};
15  
16 Match E[ maxN<<2 ] ;
17 int head [ maxN ] , match[ maxN ] ;
18 bool vis [ maxN ] ;
19  
20 int cnt = 0 ,ans = 0 ;
21  
22 void Add_Edge ( int x , int y ) {
23          E[ ++cnt ] . to = y ; 
24          E[ cnt ] . next = head[ x ] ;
25          head [ x ] = cnt ;
26 }
27  
28 bool Hungary ( int x ) {
29          for ( int i = head[ x ] ; i ; i = E[ i ] . next ) {
30                  if ( vis[ i ] ) continue ;
31                  int temp = E[ i ] . to ; 
32                  vis[ i ] = true ;
33                  if ( !match[ temp ] || Hungary ( match[ temp ] ) ) {
34                           match [ temp ] = x ;
35                           return true ;
36                  }
37          }
38          return false ;
39 } 
40  
41 int main ( ) {
42          int N , M ; 
43          memset ( match , 0 , sizeof ( match ) ) ;
44          scanf ( "%d %d" , &N , &M ) ;
45          for ( int i=1 ; i<=M ; ++i ) {
46                  int x1 , x2 ; 
47                  scanf ( "%d%d" , &x1 , &x2 ) ;
48                  Add_Edge ( i , x1 ) , Add_Edge ( i , x2 ) ;//使用邻接表储存 
49          }
50          int k ;
51          for ( k=1 ; k<=M ; ++k ) {
52                  memset ( vis , false , sizeof ( vis ) ) ; 
53                  if ( !Hungary ( k ) )
54                          break ;
55          }
56          printf ( "%d\n" , k - 1 ) ;
57          return 0 ; 
58 }