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.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class B243 {
	InputStream is;
	PrintWriter out;
	/**
	 * Go to Sublime, copy & pase the input Use Ctrl+A, Ctrl+Shift+L, Ctrl+Enter
	 * to create this string
	 */
	String INPUT = "1 3\n0 0 0";

	void solve() {
		int n = ni();
		int m = ni();
		
		int[][] arr = new int[n][m]; 
		for(int i = 0 ; i < n ; i ++) {
			arr[i] = na(m);
		}
		
		while(true) {
			debug(n);
			if(n % 2 == 1) {
				break;
			}
			
			boolean done = false;
			for(int i = 0; i < n/2; i++) {
				for(int j = 0; j < m ; j++) {
					if(arr[n/2 + i][j] != arr[n/2 - i - 1][j]) {
						done = true;
					}
				}
			}
			if(done)
				break;
			n=n/2;
		}
		out.println(n);
	}

	/**
	 * Built using CHelper plug-in Actual solution is at the top
	 */
	static final int INF = (int) 1e9;

	private static boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private static void debug(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

	static int[][] packD(int n, int[] from, int[] to) {
		int[][] result = new int[n][];
		int[] goOutCount = new int[n];
		for (int f : from)
			goOutCount[f]++;
		for (int i = 0; i < n; i++)
			result[i] = new int[goOutCount[i]];
		for (int i = 0; i < from.length; i++) {
			--goOutCount[from[i]];
			result[from[i]][goOutCount[from[i]]] = to[i];
		}
		return result;
	}

	void run() throws Exception {
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		debug(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new B243().run();
	}

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	/**
	 * Next Double.
	 */
	private double nd() {
		return Double.parseDouble(ns());
	}

	/**
	 * Next Char.
	 */
	private char nc() {
		return (char) skip();
	}

	/**
	 * Next String.
	 */
	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b !=
									// ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	/**
	 * Next Char array.
	 */
	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	/**
	 * Next Matrix.
	 */
	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	/**
	 * Next Array.
	 */
	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	/**
	 * Next Integer.
	 */
	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	/**
	 * Next Long.
	 */
	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
}