using System; using System.Collections.Generic; using System.Linq; namespace yukicodeX { public class Program { public static int Solver(System.IO.TextReader reader) { const int QTY_CUP= 3; var n = 1 << ( QTY_CUP - int.Parse( reader.ReadLine() ) ); var m = int.Parse( reader.ReadLine() ); for (var i = 0; i != m; ++i) { var buf = MyLib.GetIntList( reader.ReadLine() ); var p = 1 << ( QTY_CUP - buf[ 0 ] ); var q = 1 << ( QTY_CUP - buf[ 1 ] ); var nn = n & ( p | q ); if (nn > 0) n = n ^ ( p | q ); } return (int)( QTY_CUP - Math.Log( n ) / Math.Log( 2 ) ); } private static void Main() { Console.WriteLine( Solver( Console.In ) ); } } public class MyLib { public static string Ordinalization(int num) { string surfix = "stndrdth"; return string.Format( "{0}{1}", num, ( 0 < num % 10 && num % 10 <= 4 ) && ( ( num % 100 ) / 10 != 1 ) ? surfix.Substring( ( num % 10 - 1 ) * 2, 2 ) : surfix.Substring( 6 ) ); } public static List GetIntList(string input) { return input.Split().ToList().ConvertAll( int.Parse ); } public static List GetIntList(string input, char delimitor) { return input.Split( delimitor ).ToList().ConvertAll( int.Parse ); } public static List GetIntList(string input, char[] delimitors) { return input.Split( delimitors ).ToList().ConvertAll( int.Parse ); } } }