# Include <bits/stdc ++. h>
Using namespace STD;
Int CNT = 0;
Int flag = 0;
Int to [400007], NEX [400007], vis [100007], head [100007];
Void add (int A, int B) {// The head Insertion Method of the linked list. When the NEX array is opened to next, it will be compiled incorrectly.
To [++ CNT] = B;
Nex [CNT] = head [a];
Head [a] = CNT;
}
Void DFS (int A, int B ){
For (INT I = head [a]; I! = 0; I = NEX [I]) {// traverse the adjacent contacts of this Vertex
Int v = to [I];
If (V = B) // you have already traversed this situation in B's adjacent points.
Continue;
If (vis [v]) {// indicates that a ring exists.
Int x = vis [a];
If (X-vis [v] + 1) & 1) // The Ring length is an odd number. In this case, three colors are required.
Flag = 1;
Return;
}
Vis [v] = vis [a] + 1;
DFS (V, );
}
}
Int main (){
Int n, m;
Scanf ("% d", & N, & M );
Int X, Y;
For (INT I = 1; I <= m; I ++ ){
Scanf ("% d", & X, & Y );
Add (x, y );
Add (Y, X );
}
Vis [1] = 1;
DFS (1, 0 );
If (n = 1)
Printf ("1 ");
Else if (flag = 1)
Printf ("3 ");
Else if (flag = 0)
Printf ("2 ");
Return 0;
}
Wannafly challenge 27B (DFS, linked list head insertion)