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.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Template {
      public int[] getIntArray(String line){
        String s[] = line.trim().split(" ");
        int a[] = new int[s.length];
        for (int i=0;i<s.length;++i){
            a[i]=Integer.parseInt(s[i]);
        }
        return a;
    }
    public void solve() throws IOException {


           BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
           PrintWriter pw = new PrintWriter(System.out);


           int a[] = getIntArray(br.readLine());
           int n = a[0];
           int m = a[1];
           int h = n;
           if (n % 2 != 0) {
               System.out.println(n);
               System.exit(0);
           }
           int mat[][] = new int[n][m];
           for (int i = 0; i < n; i++) {
               mat[i] = getIntArray(br.readLine());
           }

           int count = 0;
           while (n != 1) {
               if (isIt(mat, n, m)) {
                   count++;
               } else {
                   break;
               }
               n /= 2;
              if (n % 2 != 0) {
               System.out.println(n);
               System.exit(0);
              }
           }
        // System.out.println(count);
           if (count != 0) {
               System.out.println(h /(int) Math.pow(2,count));
           }else{
               System.out.println(n);
           }
       }

       public static boolean isIt(int mat[][], int n, int m) {
           boolean valid = true;
           //System.out.println("n= "+n+"  m="+m);
           for (int i = 0; i < n / 2; i++) {
               for (int j = 0; j < m; j++) {
                   if (mat[i][j] != mat[n - 1 - i][j]) {
                       valid = false;
                   }
               }
               //System.out.println(valid+"  "+i);
           }

           return valid;

       }

    public static void main(String[] args) throws IOException {
        new Template().solve();
    }


     static long C(long n, long k) {
        double res = 1;
        for (long i = 1; i <= k; ++i) {
            res = res * (n - k + i) / i;
            System.out.println("res = "+res);
        }
        return (long) (res + 0.01);
    }
    // Use 64 bits integers to avoid overflow errors during multiplication.
    static long modPow(long a, long x, long p) {
        //calculates a^x mod p in logarithmic time.
        long res = 1;
        while(x > 0) {
            if( x % 2 != 0) {
                res = (res%p * a%p) % p;
            }
            a = (a%p * a%p) % p;
            x /= 2;
        }
        return res;
    }

    static long  modInverse(long a, long p) {
        //calculates the modular multiplicative of a mod m.
        //(assuming p is prime).
        return modPow(a, p-2, p);
    }
    static long  modBinomial(long n, long k, long p) {
    // calculates C(n,k) mod p (assuming p is prime).

        long numerator = 1; // n * (n-1) * ... * (n-k+1)
        for (long i=0; i<k; i++) {
            numerator = (numerator%p * (n-i)%p ) % p;
        }

        long denominator = 1; // k!
        for (long i=1; i<=k; i++) {
            denominator = (denominator%p * i%p) % p;
        }

        // numerator / denominator mod p.
        return ( numerator%p* modInverse(denominator,p)%p ) % p;
    }

    public static long calculate(long k, long n) {
        return  ( modBinomial(n,k, 1000000007) );
    }

}



class Utils{

    public String getLongArrayInString(long []a){
         StringBuilder sb = new StringBuilder();
          for(int i=0;i<a.length;++i){
                 sb.append(a[i]+" ");
          }
       return  sb.toString().trim();
    }

    public String getIntArrayInString(int []a){
         StringBuilder sb = new StringBuilder();
          for(int i=0;i<a.length;++i){
                 sb.append(a[i]+" ");
          }
       return  sb.toString().trim();
    }

    public Integer toInt(String s){
         return Integer.parseInt(s.trim());
    }
    public Long toLong(String s){
         return Long.parseLong(s.trim());
    }
    public Double toDouble(String s){
         return Double.parseDouble(s.trim());
    }

     public int[] getIntArray(String line){
        String s[] = line.trim().split(" ");
        int a[] = new int[s.length];
        for (int i=0;i<s.length;++i){
            a[i]=Integer.parseInt(s[i]);
        }
        return a;
    }
    public Integer[] getIntegerArray(String line){
        String s[] = line.split(" ");
        Integer a[] = new Integer[s.length];
        for (int i=0;i<s.length;++i){
            a[i]=Integer.parseInt(s[i]);
        }
        return a;
    }
      public Double[] getDoubleArray(String line){
        String s[] = line.split(" ");
        Double a[] = new Double[s.length];
        for (int i=0;i<s.length;++i){
            a[i]=Double.parseDouble(s[i]);
        }
        return a;
    }
    public Long[] getLongArray(String line){
        String s[] = line.split(" ");
        Long a[] = new Long[s.length];
        for (int i=0;i<s.length;++i){
            a[i]=Long.parseLong(s[i]);
        }
        return a;
    }

    public Long getMaxFromLongArray(Long a[]){
           Long max=Long.MIN_VALUE;
            for(int i=0;i<a.length;++i){
                if(max<a[i]){
                          max=a[i];
                }
            }
        return max;
    }
    public Long getMinFromLongArray(Long a[]){
           Long min=Long.MAX_VALUE;
            for(int i=0;i<a.length;++i){
                if(min>a[i]){
                          min=a[i];
                }
            }
        return min;
    }
     public Integer getMaxFromIntegerArray(Integer a[]){
           Integer max=Integer.MIN_VALUE;
            for(int i=0;i<a.length;++i){
                if(max<a[i]){
                          max=a[i];
                }
            }
        return max;
    }
     public Integer getMinFromIntegerArray(Integer a[]){
           Integer min=Integer.MAX_VALUE;
            for(int i=0;i<a.length;++i){
                if(min>a[i]){
                          min=a[i];
                }
            }
        return min;
    }

}
