Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties:

  * the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; 
  * the lower half of matrix c (rows with numbers from x + 1 to 2x) is symmetric to the upper one; the symmetry line is the line that separates two halves (the line that goes in the middle, between rows x and x + 1). 



Sereja has an n × m matrix a. He wants to find such matrix b, that it can be transformed into matrix a, if we'll perform on it several (possibly zero) mirrorings. What minimum number of rows can such matrix contain?

Input

The first line contains two integers, n and m (1 ≤ n, m ≤ 100). Each of the next n lines contains m integers — the elements of matrix a. The i-th line contains integers ai1, ai2, ..., aim (0 ≤ aij ≤ 1) — the i-th row of the matrix a.

Output

In the single line, print the answer to the problem — the minimum number of rows of matrix b.

Examples

Input

4 3
0 0 1
1 1 0
1 1 0
0 0 1


Output

2


Input

3 3
0 0 0
0 0 0
0 0 0


Output

3


Input

8 1
0
1
1
0
0
1
1
0


Output

2

Note

In the first test sample the answer is a 2 × 3 matrix b:
    
    
      
    001  
    110  
    

If we perform a mirroring operation with this matrix, we get the matrix a that is given in the input:
    
    
      
    001  
    110  
    110  
    001  
    
import java.util.* ;
import java.io.* ;
import java.util.regex.* ;
import java.text.* ;
import java.math.* ;

public class Main {
	public static void main( String[] args ) {
		InputStream isObj ;
		OutputStream osObj ;
		InputReader irObj ;
		PrintWriter pwObj ;
		String inputFileName , outputFileName ;
		File fObj1 , fObj2 ;
		int T , ind ;
		boolean hasMoreInput , hasTestCases ;
		ProblemSolver psObj ;
		//only variable to be changed here is hasTestCases and osObj(optional for file output)
		hasTestCases = ProblemSolver.HAS_TEST_CASES ;
		isObj = System.in ;
		osObj = System.out ;
		inputFileName = ProblemSolver.INPUT_FILE_NAME ;
		outputFileName = ProblemSolver.OUTPUT_FILE_NAME ;
		try {
			fObj1 = new File( System.getProperty( "user.dir" ).toString() + "\\" + inputFileName ) ;
			fObj2 = new File( System.getProperty( "user.dir" ).toString() + "\\" + outputFileName ) ;
			if( fObj1.exists() == false ) {
				fObj1 = new File( System.getProperty( "user.dir" ).toString() + "\\src\\" + inputFileName ) ;
				fObj2 = new File( System.getProperty( "user.dir" ).toString() + "\\src\\" + outputFileName ) ;
			}
			isObj = new FileInputStream( fObj1 ) ;
			if( ProblemSolver.DO_OUTPUT_TO_FILE == true ) {
				osObj = new FileOutputStream( fObj2 ) ;
			}
		}
		catch( Exception ex ) {
			ex.printStackTrace() ;
			isObj = System.in ;
			osObj = System.out ;
		}
		irObj = new InputReader( isObj ) ;
		pwObj = new PrintWriter( osObj ) ;
		try {
			psObj = new ProblemSolver() ;
			if( hasTestCases == true ) {
				//for input with test cases
				T = irObj.nextInt() ;
				for( ind = 1 ; ind <= T ; ind++ ) {        	
					psObj.clearPerCase() ;
					psObj.getInput( irObj ) ;
					psObj.solveCase( pwObj ) ;
				}
			}
			else {
				//for end of file input
				for( ind = 1 ; ; ind++ ) {        	
					psObj.clearPerCase() ;
					hasMoreInput = psObj.getInput( irObj ) ;
					if( hasMoreInput == false ) {
						break ;
					}
					psObj.solveCase( pwObj ) ;
				}
			}
			pwObj.flush() ;
			isObj.close() ;
			osObj.close() ;
		}
		catch( Exception ex ) {
			ex.printStackTrace() ;
			throw new RuntimeException( ex ) ;
		}
		finally {
			pwObj.close() ;
		}
	}
}

class ProblemSolver {
	public static final boolean HAS_TEST_CASES = false ;
	public static final String INPUT_FILE_NAME = "test.in" ;
	public static final String OUTPUT_FILE_NAME = "out.txt" ;
	public static final boolean DO_OUTPUT_TO_FILE = false ;
	
	private int check( int x , int y ) {
		int i , j , k ;
		for( i = x , j = y ; i <= j ; i++ , j-- ) {
			for( k = 0 ; k < this.m ; k++ ) {
				if( this.memo[ i ][ k ] != this.memo[ j ][ k ] ) {
					return 0 ;
				}
			}
		}
		return 1 ;
	}
	
	public void solveCase( PrintWriter pwObj ) {
		int i , j , k , l , u , v , a , b , c ;
		int res ;
		res = this.n ;
		if( this.n % 2 != 0 ) {
			pwObj.println( "" + this.n ) ;
		}
		else {
			for( i = 0 ; i < 1 ; i++ ) {
				for( j = 0 ; j < this.n ; j++ ) {
					c = ( ( j + 1 ) * 2 ) - 1 ;
					if( c > this.n - 1 ) {
						break ;
					}
					a = this.check( i , c ) ;
					if( a == 1 ) {
						b = 1 ;
						while( true ) {
							if( c == this.n - 1 ) {
								break ;
							}
							if( c > this.n - 1 ) {
								b = 0 ;
								break ;
							}
							c = ( ( c + 1 ) * 2 ) - 1 ;
							if( c > this.n - 1 ) {
								b = 0 ;
								break ;
							}
							a = this.check( i , c ) ;
							if( a == 0 ) {
								b = 0 ;
								break ;
							}
						}
						if( b == 1 ) {
							res = Math.min( res , j + 1 ) ;
							break ;
						}
					}
				}
			}
			pwObj.println( res ) ;	
		}
	}
	
	private void init() {
		//default values
		this.lim1 = 100010 ;
		this.lim2 = 110 ;
		this.cc = 1 ;
		this.ind = 0 ;
		this.declareArrays() ;
		this.fillAllArrays() ;
	}
	
	public boolean getInput( InputReader irObj ) {
		int i , j ;
		try {
			this.n = irObj.nextInt() ;
		}
		catch( Exception ex ) {
			return false ;
		}
		this.m = irObj.nextInt() ;
		for( i = 0 ; i < this.n ; i++ ) {
			for( j = 0 ; j < this.m ; j++ ) {
				this.memo[ i ][ j ] = irObj.nextInt() ;
			}
		}
		return true ;
	}
	
	private int lim1 , lim2 , cn , ind , cc , n , m ; 
	private String[] srr ;
	private int[] arr , brr ;
	private Node[] nrr ;
	private long[] lrr ;
	private int[][] memo , done ;
	private ArrayList< Integer >[] adj_list ;
	
	public void clearPerCase() {
		this.incrementInd() ;
		this.incrementCc() ;
		this.n = 0 ;
		this.cn = 0 ;
	}
	
	private void declareArrays() {
		//array declarations
		this.arr = new int[ this.lim1 ] ;
		this.brr = new int[ this.lim1 ] ;
		this.lrr = new long[ this.lim1 ] ;
		this.srr = new String[ this.lim1 ] ;
		this.nrr = new Node[ this.lim1 ] ;
		this.memo = new int[ this.lim2 ][ this.lim2 ] ;
		this.done = new int[ this.lim2 ][ this.lim2 ] ;
		this.adj_list = new ArrayList[ this.lim1 ] ;
	}
	
	private void fillAllArrays() {
		int i ;
		//array initiations
		Arrays.fill( this.arr , 0 ) ;
		Arrays.fill( this.brr , 0 ) ;
		Arrays.fill( this.lrr , 0 ) ;
		for( int zrr[] : this.done ) {
			Arrays.fill( zrr , 0 ) ;
		}
		for( i = 0 ; i < this.lim1 ; i++ ) {
			this.srr[ i ] = new String( "" ) ;
			this.nrr[ i ] = new Node( Integer.MIN_VALUE , Integer.MIN_VALUE ) ;
			this.adj_list[ i ] = new ArrayList< Integer >() ;
		}
	}
	
	private void incrementInd() {
		this.ind++ ;
	}
	
	public void setCn( int c ) {
		this.cn = c ;  
	}
	
	public void incrementCn() {
		this.cn++ ;
	}
	
	public void incrementCc() {
		this.cc++ ;
	}
	
	public int getCn() {
		return this.cn ;
	}
	
	public ProblemSolver() {
		this.init() ;
	}
}

class Node implements Comparable< Node > {
	private int v , f ;
	
	private Node() {
	}
	
	public Node( int vParam , int fParam ) {
		this.v = vParam ;
		this.f = fParam ;
	}
	
	public void setV( int vParam ) {
		this.v = vParam ;
	}
	
	public void setF( int fParam ) {
		this.f = fParam ;
	}
	
	public int getV() {
		return this.v ;
	}
	
	public int getF() {
		return this.f ;
	}
	
	public int compareTo( Node nParam ) {
		return this.getV() - nParam.getV() ;
	}
}

class InputReader {
	private BufferedReader reader ;
	private StringTokenizer tokenizer ;

	public InputReader( InputStream stream ) {
		this.reader = new BufferedReader( new InputStreamReader( stream ) ) ;
		this.tokenizer = null ;
	}

	private String next( int fl ) {
		while( this.tokenizer == null || ! this.tokenizer.hasMoreTokens() ) {
			try {                
				this.tokenizer = new StringTokenizer( this.reader.readLine() ) ;
			}
			catch( IOException e ) {
				throw new RuntimeException( e ) ;
			}
		}
		String s ;
		s = "" ;
		if( fl == 1 ) {
			s = this.tokenizer.nextToken() ; 
		}
		return s ;
	}

	public String nextLine() {
		this.next( 0 ) ;
		int fl ;
		String line ;
		line = "" ;
		fl = 0 ;
		if( this.tokenizer != null ) {
			while( this.tokenizer.hasMoreTokens() ) {
				if( fl == 1 ) {
					line += " " ;
				}
				fl = 1 ;
				line += this.tokenizer.nextToken() ;
			}
		}
		return line ;
	}

	public int nextInt() {
		return Integer.parseInt( this.next( 1 ) ) ;
	}

	public long nextLong() {
		return Long.parseLong( this.next( 1 ) ) ;
	}

	public double nextDouble() {
		return Double.parseDouble( this.next( 1 ) ) ;
	}

	public String nextString() {
		return this.next( 1 ) ;
	}
}
