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.math.*;

public class Main {

    InputReader ir = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    final long kmod = 993960000099397l;
    
    void solve() {
        int n = ir.readInt();
        int m = ir.readInt();
        String arr[] = new String[n];
        for(int i = 0; i < n; i++) {
            String temp = "";
            for(int j = 0; j < m; j++) {
                temp += ir.readInt();
            }
            arr[i] = temp;
        }

        for(int i = 1; i <= n/2; i++) {
            int temp = i;
            while(temp < n)
                temp *= 2;
            if(temp != n)
                continue;
            if(n % i == 0) {
                String correct[] = new String[i];
                String rev[] = new String[i];
                for(int j = 0; j < i; j++) {
                    correct[j] = arr[j];
                    rev[j] = arr[i - j - 1];
                }
                int cnt = 0;
                boolean f = true;
                for(int j = 0; j < n && f == true; j += i) {
                    if(cnt % 2 == 0) {
                        cnt++;
                        for(int k = 0; k < i; k++) {
                            if(arr[j + k].compareTo(correct[k]) == 0) {
                                f &= true;
                            } else {
                                f &= false;
                            }
                        }
                    } else {
                        cnt++;
                        for(int k = 0; k < i; k++) {
                           
                            if(arr[j + k].compareTo(rev[k]) == 0) {
                                f &= true;
                            } else {
                                f &= false;
                            }
                        }
                    }
                }
                if(f) {
                    out.println(i);
                    return;
                }
            }
        }
        out.println(n);
    }

    void run() {
        solve();
        out.close();
    }
    public static void main(String args[]){
        new Main().run();
    }
}

class InputReader {
 
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;
 
    public InputReader(InputStream stream) {
        this.stream = stream;
    }
 
    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }
    public final int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
    }
    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
 
    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }
        public double readDouble() {
        return Double.parseDouble(readString());
    }
 
    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
 
    public String next() {
        return readString();
    }
 
    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}