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.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

import static java.lang.Math.*;
 
public class solver implements Runnable {
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");
        
        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        try{
                                tok = new StringTokenizer(in.readLine());
                        }catch (Exception e){
                                return null;
                        }
                }
                return tok.nextToken();
        }
        String readString(String delim) throws IOException{
            while(!tok.hasMoreTokens()){
                    try{
                            tok = new StringTokenizer(in.readLine());
                    }catch (Exception e){
                            return null;
                    }
            }
            return tok.nextToken(delim);
    }
       
        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }  
        long readLong() throws IOException{
                return Long.parseLong(readString());
        }      
        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        } 
        char readChar() throws IOException {
            char val = 0;
            do{
                val = (char) in.read();
            }while(val == '\n' || val == '\r');
            return val;
        }
        char readChar(String skipChars)throws IOException{
            char val = 0;
            boolean ret;
            do{
                val = (char) in.read();
                ret = false;
                for (int i = skipChars.length()-1; i >= 0; i--){
                    if (skipChars.charAt(i) == val){
                        ret = true;
                        break;
                    }
                }
            }while(ret);
            return val;
        }
        
        void readIntArray(int[] arr, int start, int count) throws IOException{
            for (int i = 0; i < count; i++){
                arr[i+start] = readInt();
            }
        }
        
        public class Pair<T1,T2> {
            public T1 x1;
            public T2 x2;
            public Pair(){};
            public Pair(T1 x1, T2 x2){
                this.x1 = x1;
                this.x2 = x2;
            }
            public String toString(){
                return x1.toString() + " " + x2.toString();
            }
        }
        public class Point implements Comparable<Point>{
            public int x1, x2;
            public Point(){}
            public Point(int a, int b){x1 = a;x2=b;}
            public int compareTo(Point o) {
                return (x1-o.x1);
            }
            public String toString(){
                return x1 + ":" + x2;
            }
        }
        public class Tree implements Comparable<Tree>{
            public int x1, x2, x3;
            public Tree(){}
            public Tree(int a, int b, int c){x1 = a;x2=b;x3=c;}
            public int compareTo(Tree o) {
                if (x2 == o.x2) return (o.x1 - x1);
                return -(x2-o.x2);
            }
            public String toString(){
                return x1 + ":" + x2  + ":" +x3;
            }
        }
//----------------------------------------        
        
        
        public void solve() throws IOException {
            int n = readInt();
            int m = readInt();
            int[][] arr =  new int[n][];
            for (int i = 0; i < n; i++){
                arr[i] = new int[m];
                readIntArray(arr[i], 0, m);
            }
            
            int ans = 0;
            while(true){
                if (n%2 != 0) break;
                for (int i = 0; i < n/2; i++){
                    for (int j = 0; j < m; j++)
                    if (arr[i][j] != arr[n-1-i][j]){{
                        out.print(n);
                        return;
                        
                    }
                    }
                }
                n/=2;
                ans++;
            }
            out.print(n);
            
        }
        
        
//----------------------------------------
        public static void main(String[] args){
                new Thread(null, new solver(), "", 256 * (1L << 20)).start();
        }
       
        public void run(){
                try{
                        timeBegin = System.currentTimeMillis();
                        
                        if (ONLINE_JUDGE){
                            in = new BufferedReader(new InputStreamReader(System.in));
                            out = new PrintWriter(System.out);
                        } 
                        else {
                            in = new BufferedReader(new FileReader("input.txt"));
                            out = new PrintWriter("output.txt");
                        }
                        
                        solve();
                        out.close();
                        
                        timeEnd = System.currentTimeMillis();
                        System.err.println("Time = " + (timeEnd - timeBegin));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }
       
        long timeBegin, timeEnd;
 
        
//-------ДЕРЕВО ОТРЕЗКОВ       
        int[] doo;
        
        void update(int v, int i, int val, int ll, int rr){
            if (ll == rr){
                doo[v] = val;
            }else{
                int med = ll + (rr-ll)/2;
                
                if (i <= med){
                    update(2*v, i, val, ll, med);
                }else{
                    update(2*v+1, i, val, med+1, rr);
                }
                doo[v] = max(doo[2*v],doo[2*v+1]);
            }
        }
        int get(int v, int l, int r, int ll, int rr){
            if (l > r){
                return 0;
            }
            if (ll == l && r == rr){
                return doo[v];
            }
            int med = ll +(rr-ll)/2;
            return max(get(2*v, l, min(r, med), ll, med), 
                    get(2*v+1, max(l, med+1), r, med+1, rr));
        }
 //----------------------------------------         
}