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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Test {
	public static void main(String[] args) {
		// try {
		// InputStream inputStream = new FileInputStream(
		// "D:\\codeforse\\CF\\input.txt");
		// OutputStream outputStream = new FileOutputStream(
		// "D:\\codeforse\\CF\\output.txt");
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C solver = new C();
		// int t = in.nextInt();
		// for (int i = 1; i <= t; i++) {
		solver.solve(1, in, out);
		// }
		out.close();
		// } catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		// e.printStackTrace();
		// } catch (IOException e) {
		// TODO Auto-generated catch block
		// e.printStackTrace();
		// }
	}
}

class C {

	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt();

		int m = in.nextInt();
		
		String[] s = new String[n];
		
		for (int i = 0; i < n; i++) {
			s[i] = "";
			for (int j=0; j < m; j++){
				s[i] += in.nextString(); 
			}
		}
		boolean good;
		while (n%2 == 0){
			//System.out.println(n);
			good = true;
			for (int i = 0; i < n/2; i++){
				if (!s[i].equals(s[n-i-1])){
					good = false;
					break;
				}
			}
			if (good){
				n = n/2;
			}else{
				break;
			}
		}
		
		out.print(n);

	}

	class Pair implements Comparable<Pair> {
		// ArrayList<Pair> p = new ArrayList<Pair>();
		// Collections.sort(p, Comparators.AGE);
		int r;

		ArrayList<Pair> pp;
		int me;

		public Pair(int a) {
			me = a;
			pp = new ArrayList<Pair>();
		}

		public void add(Pair p) {
			pp.add(p);
		}

		public int get(int from) {
			int sum = 0;
			ArrayList<Integer> ans = new ArrayList<Integer>();
			for (Pair p : pp) {
				if (p.me != from || from == -1) {
					// sum += p.get(false);
					int t = p.get(this.me);
					if (t > 0) {
						ans.add(t);
					}
				}
			}
			int l = ans.size();
			if (l == 0) {
				return 1;
			} else if (l == 1) {
				return 1;
			} else {
				Collections.sort(ans);
				// System.out.println(l);
				for (int i = l - 1; i >= l - 2; i--) {
					// System.out.println(i);
					sum += ans.get(i);
				}
				return sum + 1;
			}
		}

		@Override
		public int compareTo(Pair o) {
			return Comparators.AGE.compare(this, o);
		}

		public String toString() {
			return "" + r + " ";
		}

	}

	public static class Comparators {

		public static Comparator<Pair> AGE = new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				return o1.r > o2.r ? 1 : (o1.r < o2.r ? -1 : 0);
			}
		};
	}
}

class InputReader {

	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public Double nextDouble() {
		return Double.parseDouble(next());
	}

	public String nextString() {
		return next();
	}

}
