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.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

import javax.security.auth.kerberos.KerberosKey;
import javax.tools.JavaFileObject.Kind;

import static java.lang.Math.*;

public class Main {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok = new StringTokenizer("");

	void init() throws FileNotFoundException {
		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");
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	int gcd(int a, int b) {
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}


	int fib(int n) {
		if (n == 1)
			return 1;
		if (n == 2)
			return 2;
		else
			return fib(n - 1) + fib(n - 2);
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	public static void main(String[] args) {
		new Main().run();
		// Sworn to fight and die
	}

	public static void mergeSort(int[] a) {
		mergeSort(a, 0, a.length - 1);
	}

	private static void mergeSort(int[] a, int levtIndex, int rightIndex) {
		final int MAGIC_VALUE = 50;
		if (levtIndex < rightIndex) {
			if (rightIndex - levtIndex <= MAGIC_VALUE) {
				insertionSort(a, levtIndex, rightIndex);
			} else {
				int middleIndex = (levtIndex + rightIndex) / 2;
				mergeSort(a, levtIndex, middleIndex);
				mergeSort(a, middleIndex + 1, rightIndex);
				merge(a, levtIndex, middleIndex, rightIndex);
			}
		}
	}

	private static void merge(int[] a, int levtIndex, int middleIndex,
			int rightIndex) {
		int length1 = middleIndex - levtIndex + 1;
		int length2 = rightIndex - middleIndex;
		int[] levtArray = new int[length1];
		int[] rightArray = new int[length2];
		System.arraycopy(a, levtIndex, levtArray, 0, length1);
		System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
		for (int k = levtIndex, i = 0, j = 0; k <= rightIndex; k++) {
			if (i == length1) {
				a[k] = rightArray[j++];
			} else if (j == length2) {
				a[k] = levtArray[i++];
			} else {
				a[k] = levtArray[i] <= rightArray[j] ? levtArray[i++]
						: rightArray[j++];
			}
		}
	}

	private static void insertionSort(int[] a, int levtIndex, int rightIndex) {
		for (int i = levtIndex + 1; i <= rightIndex; i++) {
			int current = a[i];
			int j = i - 1;
			while (j >= levtIndex && a[j] > current) {
				a[j + 1] = a[j];
				j--;
			}
			a[j + 1] = current;
		}
	}

	public void run() {
		try {
			long t1 = System.currentTimeMillis();
			init();
			solve();
			out.close();
			long t2 = System.currentTimeMillis();
			System.err.println("Time = " + (t2 - t1));
		} catch (Exception e) {
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}
	

	class LOL implements Comparable<LOL> {
		int x;
		int y;


		public LOL(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(LOL o) {

			//if (y == o.y)
			//	return (o.x - x);
			return x - o.x; // ---->
			// return o.x - x; // <----
			// return o.y-y;
		}

	}
	public int binarySearch(int []a, int k) {
		int l = 0, r = a.length - 1;
		while (l <= r) {
			int m = (l + r)/2;
			if (a[m] == k) return m;
			else if (a[m] > k) r = m - 1;
			else l = m + 1;
		}
		return -1;
	}
	
	public long prxor(long n) {
		int m = (int) (n%4);
		switch (m) {
		case 0 : return n;
		case 1 : return 1;
		case 2 : return n+1;
		case 3 : return 0;
		}
		return 1;
	}


	public void solve() throws IOException {
				
			int n = readInt();
			int m = readInt();
			boolean f = true;
			
			int[][] a = new int[n][m];
			
			for ( int i = 0; i < n; i++)
				for (int j = 0; j < m ; j++)
					a[i][j] = readInt();
			
			while (n%2==0 && f) {
				for ( int i = 0; i < n/2; i++)
					for (int j = 0; j < m ; j++) 
						if (a[i][j] != a [n - i - 1][j]) f = false;
					if (f) n/=2;
			}
			
			out.print(n);
		}
		
		
}