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 a_{i}1, a_{i}2, ..., a_{im} (0 ≤ a_{ij} ≤ 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

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
(n, m) = map(int, input().split())
if n & 1:
	print(n)
else:
	(k, t) = (n // 2, [int(input()[::2], 2) for i in range(n)])
	while True:
		if t[:k] != t[k:2 * k][::-1]:
			print(2 * k)
			break
		elif k & 1:
			print(k)
			break
		k //= 2


__author__ = 'Lipen'

def main():
	(n, m) = map(int, input().split())
	a = []
	for _ in range(n):
		a.append(input())
	while n % 2 == 0:
		if a[:n // 2] != a[:n // 2 - 1:-1]:
			break
		n //= 2
		a = a[:n]
	print(n)
main()


(n, m) = map(int, input().split())
arr = [input() for i in range(n)]
while n % 2 == 0 and arr[:n] == list(reversed(arr[:n])):
	n //= 2
print(n)


(n, m) = list(map(int, input().split()))
a = []
for _ in range(n):
	a.append(list(map(int, input().split())))

def isMirror(l):
	y = len(l)
	if y % 2 != 0:
		return False
	y = y // 2
	lb = l[:y]
	le = l[y:]
	if le[::-1] == lb:
		return True
	else:
		return False
while isMirror(a):
	a = a[:len(a) // 2]
print(len(a))


(n, m) = map(int, input().split())
ans = n
arr = []
for i in range(n):
	arr.append(input())
while True:
	if n & 1:
		print(ans)
		break
	else:
		k = n // 2
		for i in range(k):
			if arr[i] != arr[n - i - 1]:
				print(ans)
				return
		n = k
		ans = n


(n, m) = map(int, input().split())
mat = [input() for _ in range(n)]
while n > 1 and n % 2 == 0:
	if mat[:n] != list(reversed(mat[:n])):
		break
	n //= 2
print(n)


R = lambda : list(map(int, input().split()))

def check(row):
	return a[0:row // 2] == a[row - 1:row // 2 - 1:-1]
(m, n) = R()
a = [input() for i in range(m)]
row = m
while row % 2 == 0 and check(row):
	row //= 2
print(row)


def can_mirror(matrix):
	if len(matrix) % 2 != 0:
		return False
	mid = len(matrix) // 2
	for i in range(mid):
		lower = -i - 1
		if matrix[mid + lower] != matrix[mid + i]:
			return False
	return True

def mirror(matrx):
	mid = len(matrix) // 2
	return matrix[:mid]
(n, m) = list(map(int, input().split()))
matrix = []
for i in range(n):
	matrix.append(list(map(int, input().split())))
while can_mirror(matrix):
	matrix = mirror(matrix)
print(len(matrix))


def pretty_print_list(a):
	for aa in a:
		print(*aa)
(m, n) = list(map(int, input().split()))
a = [[i for i in map(int, input().split())] for _ in range(m)]
if m % 2:
	print(m)
	return
m2 = m
while not m2 % 2:
	m2 //= 2
	for i in range(m2):
		if a[i] != a[2 * m2 - i - 1]:
			print(m2 * 2)
			return
print(m2)


(n, m) = map(int, input().split())
matrix = []
for i in range(n):
	matrix.append([int(x) for x in input().split()])

def mirror(matrix):
	mirrormatrix = matrix[:]
	matrix.reverse()
	mirrormatrix += matrix[:]
	matrix.reverse()
	return mirrormatrix
while True:
	if len(matrix) % 2 == 0:
		if mirror(matrix[:int(len(matrix) / 2)]) == matrix:
			matrix = matrix[:int(len(matrix) / 2)]
		else:
			print(len(matrix))
			break
	else:
		print(len(matrix))
		break


(a, b) = map(int, input().split())
if a % 2 == 0:
	s = [0] * a
	for i in range(a):
		s[i] = [0] * b
		s[i] = list(map(int, input().split()))
	while s[:a // 2] == s[:a // 2 - 1:-1] and len(s) > 1:
		a = a // 2
		s = s[:a]
else:
	for i in range(a):
		n = input()
print(a)


import sys
(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(''.join(input().split()))
if n == 1:
	print(1)
	return
if n % 2:
	print(n)
	return
d = n // 2
small = n
while d:
	i = d - 1
	symmetry = True
	for j in range(d, 2 * d, 1):
		if a[i] != a[j]:
			symmetry = False
			break
		i -= 1
	if symmetry:
		small = d
	else:
		break
	if d % 2:
		break
	d //= 2
print(small)


(n, m) = map(int, input().split())
matrix = []
for i in range(n):
	arr = list(map(int, input().split()))
	matrix.append(arr)
while n and n & 1 == 0:
	t = n // 2
	flag = True
	for i in range(n):
		if matrix[i] != matrix[n - 1 - i]:
			flag = False
	if flag == False:
		break
	else:
		n >>= 1
print(n)


(n, m) = map(int, input().split())
matrix = []
for i in range(n):
	matrix.append(list(map(int, input().split())))

def isequal(m1, m2):
	for i in range(len(m1)):
		for j in range(len(m1[i])):
			if m1[i][j] != m2[i][j]:
				return False
	return True
if n % 2 != 0:
	print(n)
else:
	m1 = matrix[0:int(len(matrix) / 2)]
	m2 = matrix[int(len(matrix) / 2):len(matrix)]
	m2.reverse()
	size = len(matrix)
	while isequal(m1, m2):
		size = len(m1)
		if len(m1) % 2 != 0:
			break
		m2 = m1[int(len(m1) / 2):len(m1)]
		m2.reverse()
		m1 = m1[0:int(len(m1) / 2)]
	print(size)


(n, m) = map(int, input().split())
mat = []
for i in range(n):
	mat.append([list(map(int, input().split()))])
i = n
l = n
while i % 2 == 0:
	l = i // 2 - 1
	for k in range(l, -1, -1):
		if mat[k] != mat[i - k - 1]:
			print(i)
			exit()
	i = i // 2
print(i)


def solve():
	(rows, cols) = list(map(int, input().split(' ')))
	arr = []
	for i in range(rows):
		arr.append(list(map(int, input().split(' '))))
	while rows % 2 == 0:
		for j in range(rows // 2):
			if arr[j] != arr[rows - j - 1]:
				print(rows)
				return
		rows = int(rows // 2)
	print(rows)
solve()


def symetry(a, n, m):
	symmetry = 0
	k = n // 2
	for x in range(n):
		for y in range(m):
			k = n - x - 1
			if k < n - 1 and a[x][y] != a[k][y]:
				symmetry = 1
	return symmetry
(n, m) = list(map(int, input().split()))
list_anmi = [list(map(int, input().split())) for i in range(n)]
sym = 0
while n % 2 == 0:
	if symetry(list_anmi[0:n], n, m) == 0:
		n = n // 2
	else:
		break
sym = n
print(sym)


(m, n) = map(int, input().split())
a = [[i for i in map(int, input().split())] for _ in range(m)]
while m % 2 == 0:
	if m % 2:
		print(m)
		exit()
	(ok, i, j) = (True, 0, m - 1)
	while ok and j > i:
		if a[i] == a[j]:
			i += 1
			j -= 1
		else:
			ok = False
			break
	if ok:
		m = int(m / 2)
		a = a[:m]
	else:
		break
print(m)


from math import log
(row, col) = map(int, input().split(' '))
if row % 2 == 1:
	print(row)
else:
	matrix = []
	for _ in range(row):
		matrix.append(input().split(' '))
	minimum = row
	for _ in range(int(log(row, 2))):
		if matrix[0:minimum // 2] == matrix[minimum - 1:minimum // 2 - 1:-1]:
			minimum //= 2
		else:
			break
	print(minimum)


(n, m) = [int(x) for x in input().split()]
a = [input() for i in range(n)]
k = 0
while True:
	if n % 2:
		break
	br = False
	for i in range(n // 2):
		if a[i] != a[n - i - 1]:
			br = True
			break
	if br:
		break
	k += 1
	n //= 2
print(n)


def checkMatr(a):
	res = True
	ln = len(a)
	hln = int(ln / 2)
	if ln % 2 != 0:
		res = False
	else:
		for i in range(hln):
			if a[i] != a[ln - 1 - i]:
				res = False
	return res
(n, m) = list(map(int, input().split()))
table = []
for i in range(n):
	table.append(str(input()))
while checkMatr(table):
	table = table[:int(len(table) / 2)]
print(len(table))


import sys
(n, m) = map(int, input().split())
mat = []
can = True
for i in range(n):
	mat += [list(map(int, input().split()))]
else:
	while can:
		if n % 2 == 1:
			print(n)
			sys.exit()
		for i in range(n // 2):
			if mat[i] != mat[n - i - 1]:
				can = False
				break
		else:
			n //= 2
print(n)


(n, m) = [int(i) for i in input().split()]
a = []
for i in range(n):
	a.append(input())
result = n
flag = True
while n % 2 == 0:
	n = int(n / 2)
	x1 = n
	x2 = n + 1
	while x1 > 0:
		if a[x1 - 1] != a[x2 - 1]:
			flag = False
			break
		x1 -= 1
		x2 += 1
	if flag == False:
		break
	result = n
print(result)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(''.join(list(map(str, input().split()))))
while not n % 2:
	if l[:n // 2] != l[n // 2:n][::-1]:
		break
	n //= 2
print(n)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(str, input().split())))
while not n % 2 and l[:n // 2] == l[n // 2:n][::-1]:
	n //= 2
print(n)


(n, m) = [int(i) for i in input().split()]
a = [input().split() for i in range(n)]
while n % 2 == 0:
	if a[:n // 2] == a[n // 2:n][::-1]:
		n //= 2
	else:
		break
print(n)


import sys

def mirror(row, matrix):
	if row % 2:
		return row
	else:
		for i in range(row // 2):
			if matrix[i] != matrix[row - 1 - i]:
				return row
		return mirror(row // 2, matrix)
(n, m) = map(int, sys.stdin.readline().split())
matrix = [list(map(int, i.split())) for i in sys.stdin.readlines()]
print(mirror(n, matrix))


import sys
import math
from collections import defaultdict
import itertools
MAXNUM = math.inf
MINNUM = -1 * math.inf

def getInt():
	return int(sys.stdin.readline().rstrip())

def getInts():
	return map(int, sys.stdin.readline().rstrip().split(' '))

def getString():
	return sys.stdin.readline().rstrip()

def printOutput(ans):
	sys.stdout.write()
	pass

def solve(grid):
	if len(grid) % 2 == 1:
		return len(grid)
	x = len(grid)
	while x % 2 == 0:
		x //= 2
	for k in range(x, len(grid) + 1):
		seq = [i for i in range(k)]
		cur = 0
		total = 0
		for line in grid:
			if line == grid[seq[cur]]:
				total += 1
				cur += 1
				if cur == len(seq):
					seq = [i for i in reversed(seq)]
					cur = 0
			else:
				break
		if total == len(grid) and cur == 0:
			return k
	return len(grid)

def readinput():
	(n, m) = getInts()
	grid = []
	for _ in range(n):
		grid.append(getString())
	print(solve(grid))
readinput()


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

def pol(x, y):
	if y % 2 != 0:
		return False
	(l, r) = (0, y - 1)
	while l < r:
		if a[l][x] != a[r][x]:
			return False
		l += 1
		r -= 1
	return True
result = 1
for i in range(m):
	j = n
	while pol(i, j):
		j //= 2
	result = max(result, j)
print(result)


(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(input())
b = n % 2 == 0
while b:
	b = True
	for i in range(n // 2):
		if a[i] != a[n - i - 1]:
			b = False
			break
	b = b and n % 2 == 0
	if b:
		n = n // 2
print(n)


def arotate(x):
	d = len(x)
	c = 0
	if d % 2 == 0:
		for i in range(int(d / 2)):
			if x[i] == x[d - i - 1]:
				c += 1
		if c == d / 2:
			return x[:int(d / 2)]
	else:
		return False
(n, m) = input().split()
n = int(n)
m = int(m)
C = []
for i in range(n):
	C += [list(map(int, input().split()))]
E = True
cnt = len(C)
while C:
	C = arotate(C)
	if C:
		cnt = len(C)
print(cnt)


import re
import inspect
from sys import argv, exit

def rstr():
	return input()

def rint():
	return int(input())

def rints(splitchar=' '):
	return [int(i) for i in input().split(splitchar)]

def varnames(obj, namespace=globals()):
	return [name for name in namespace if namespace[name] is obj]

def pvar(var, override=False):
	prnt(varnames(var), var)

def prnt(*args, override=False):
	if '-v' in argv or override:
		print(*args)

def arreq(a1, a2):
	for (a, b) in zip(a1, a2):
		if a != b:
			return False
	return True

def matches(mat):
	matlen = len(mat)
	if matlen % 2 != 0:
		return False
	for i in range(0, int(matlen / 2)):
		endrow = len(mat) - i - 1
		prnt('endrow', endrow)
		if not arreq(mat[i], mat[endrow]):
			return False
	return True
(n, m) = rints()
mat = [rints() for i in range(n)]
while matches(mat):
	mat = mat[:int(len(mat) / 2)]
print(len(mat))


def main():
	(n, m) = map(int, input().split())
	a = [[int(c) for c in input().split()] for _ in range(n)]
	if n % 2 == 1:
		print(n)
		return
	while n % 2 == 0:
		for i in range(n // 2):
			if a[i] != a[n - i - 1]:
				print(n)
				return
		n //= 2
	print(n)
main()


line = input()
(rows, cols) = line.split()
(rows, cols) = (int(rows), int(cols))
grid = []
for i in range(rows):
	line = input()
	a = [int(z) for z in line.split()]
	grid.append(a)
if rows % 2 != 0:
	print(rows)
else:
	half = int(rows / 2)
	row_count = rows
	can_go = True
	while can_go == True and row_count > 1:
		for i in range(half):
			if grid[half - i - 1] != grid[i + half]:
				can_go = False
				break
		if can_go == True and half % 2 == 0:
			row_count = int(row_count / 2)
			half = int(half / 2)
		elif can_go == True:
			row_count = int(row_count / 2)
			can_go = False
	print(row_count)


def f(c):
	n = len(c)
	if n % 2 == 1:
		return n
	for i in range(n):
		if c[i] != c[n - i - 1]:
			return n
	return f(c[:n // 2])
(n, m) = map(int, input().split())
c = [input() for i in range(n)]
print(f(c))


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))

def ok(ar1, ar2):
	l = len(ar1)
	for i in range(l):
		if ar1[i] != ar2[l - i - 1]:
			return False
	return True

def process(ar):
	if len(ar) % 2 == 1:
		return len(ar)
	if ok(ar[:len(ar) // 2], ar[len(ar) // 2:]):
		return process(ar[:len(ar) // 2])
	else:
		return len(ar)
s = process(a)
print(s)


def valid(n, arr):
	if n != int(n):
		return len(arr)
	n = int(n)
	for i in range(0, n):
		if arr[i] == arr[2 * n - 1 - i]:
			continue
		else:
			return len(arr)
	if n == 0:
		return 0
	curr_ans = n
	return min(curr_ans, valid(n / 2, arr))

def main(arr):
	return valid(len(arr) / 2, arr)
(n, m) = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
print(main(arr))


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(input()))
if n % 2 != 0:
	print(n)
else:
	start = n
	mid = n // 2
	while start != 1:
		if l[0:mid][::-1] == l[mid:start]:
			start //= 2
			mid = start // 2
		else:
			break
	print(start)


class CodeforcesTask426BSolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.matrix = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		for x in range(self.n_m[0]):
			self.matrix.append([int(y) for y in input().split(' ')])

	def process_task(self):
		size = self.n_m[0]
		while not size % 2:
			mirrorify = True
			for x in range(size // 2):
				if self.matrix[x] != self.matrix[size - x - 1]:
					mirrorify = False
					break
			if not mirrorify:
				break
			else:
				size //= 2
		self.result = str(size)

	def get_result(self):
		return self.result
Solution = CodeforcesTask426BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import stdin

def isreversed(a):
	if len(a) % 2 == 0:
		if a[:len(a) // 2] == a[len(a) // 2:][::-1]:
			return True
	return False
a = []
(n, m) = list(map(int, stdin.readline().split()))
for i in range(n):
	a.append(list(map(int, stdin.readline().split())))
res = n
while isreversed(a):
	res //= 2
	a = a[:len(a) // 2]
print(res)


(n, m) = input().split()
(n, m) = (int(n), int(m))
lis = []
for i in range(n):
	lis.append(input().split())

def sym(lis):
	c = 1
	if len(lis) % 2 != 0:
		c = 0
	else:
		for i in range(len(lis) // 2):
			if lis[i] != lis[len(lis) - 1 - i]:
				c = 0
	return c
while sym(lis) == 1:
	lis = lis[0:len(lis) // 2]
print(len(lis))


from sys import stdin, stdout
from os import path
rd = lambda : stdin.readline().strip()
wr = stdout.write
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
import time, math
(x, y) = map(int, rd().split())
mylist = [''.join(map(str, rd().split())) for _ in range(x)]
while x > 1 and x % 2 == 0:
	if mylist[:x] != mylist[:x][::-1]:
		break
	x //= 2
print(x)


string_input = input().split(' ')
(n, m) = (int(string_input[0]), int(string_input[1]))
matrix = []
row = n
for i in range(0, n):
	matrix.append(input())
while True:
	if n % 2 == 1:
		break
	else:
		row_flag = 1
		n = n // 2
		for i in range(0, n):
			if matrix[i] != matrix[2 * n - 1 - i]:
				row_flag = 0
				break
		if row_flag:
			row = n
		else:
			break
print(row)


def solve(n, a):
	return n if n % 2 == 1 or any((a[i] != a[n - i - 1] for i in range(n // 2))) else solve(n // 2, a)

def main():
	(n, _) = map(int, input().split())
	a = [[int(c) for c in input().split()] for _ in range(n)]
	ans = solve(n, a)
	print(ans)
main()


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(''.join(input().split()))
while n % 2 == 0:
	k = 0
	for i in range(n // 2):
		if a[i] == a[n - i - 1]:
			k += 1
	if k != n // 2:
		break
	n = n // 2
print(n)


(n, m) = map(int, input().split())
arr = [input() for i in range(n)]
while n % 2 == 0:
	if arr[:n] == list(reversed(arr[:n])):
		n //= 2
	else:
		break
print(n)


(n, m) = [int(c) for c in input().split()]
field = []
for i in range(n):
	field.append([int(c) for c in input().split()])
min = n
s = 1
while min > 0 and min % 2 == 0 and s:
	t = field[min // 2:min]
	t.reverse()
	if field[:min // 2] == t:
		min = min // 2
	else:
		s = 0
print(min)


def arr_2d(n):
	return [[int(x) for x in stdin.readline().split()] for i in range(n)]

def factorize(n):
	(c, ans) = (1, [])
	while c * c < n:
		if n % c == 0:
			ans.extend([c, n // c])
		c += 1
	if c * c == n:
		ans.append(c)
	return sorted(ans)
from sys import stdin
(n, m) = map(int, input().split())
(mat, div) = (arr_2d(n), factorize(n))
if n & 1:
	print(n)
else:
	arr = []
	for (i, j) in enumerate(div):
		(arr, c) = (mat[:j], 1)
		for k in range(j, n + 1, j):
			if c % 2 and arr == list(reversed(mat[k:k + j])) or (c % 2 == 0 and arr == mat[k:k + j]):
				c += 1
			else:
				break
		if c == n // j and c % 2 ** (len(bin(c)[2:]) - 1) == 0:
			exit(print(j))
	print(n)


(n, m) = map(int, input().split())
mat = [input() for _ in range(n)]
ans = n
while ans > 1 and ans % 2 == 0:
	if mat[:ans] == list(reversed(mat[:ans])):
		ans //= 2
	else:
		break
	if ans == 1:
		if len(set(mat)) > 1:
			ans = 2
		break
print(ans)


def readln():
	return tuple(map(int, input().split()))
(n, m) = readln()
a = [readln() for _ in range(n)]
ans = n
while ans % 2 == 0:
	p1 = a[:ans // 2]
	p2 = a[ans // 2:]
	p2.reverse()
	if p1 != p2:
		break
	a = p1
	ans //= 2
print(ans)


mtxSize = list(map(int, input().split()))
rows = mtxSize[0]
inArray = []
for i in range(rows):
	inputs = list(map(int, input().split()))
	inArray.append(inputs)
revArray = inArray[::-1]
while rows % 2 == 0:
	if inArray == revArray:
		rows //= 2
		del inArray[rows:]
		del revArray[:rows]
	else:
		break
print(rows)


def check(i, j):
	global a
	while i < j:
		if a[i] != a[j]:
			return False
		i += 1
		j -= 1
	return True
(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(input().strip())
last = n
while last % 2 == 0:
	if check(0, last - 1):
		last //= 2
	else:
		break
print(last)


def check(n, m, a):
	for i in range(n // 2):
		for j in range(m):
			if a[i][j] != a[-i - 1][j]:
				return 0
	if n % 2:
		return 0
	return 1

def new(n, a):
	return a[:(n + 1) // 2]
(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
cnt = 0
while not n % 2 and check(n, m, a):
	a = new(n, a)
	n //= 2
print(len(a))


(a, b) = map(int, input().split())
z = [input() for _ in ' ' * a]
s = 0
for i in range(a):
	ok = 0
	p = i + 1
	while 1:
		if p >= a:
			ok = 1
			break
		if z[:p] == z[p:2 * p][::-1]:
			p *= 2
		else:
			break
	if ok:
		print(i + 1)
		exit()


(n, m) = tuple(map(int, str.split(input())))
a = list(map(lambda _: input(), range(n)))
while n % 2 == 0 and all(map(lambda i: a[i] == a[-i - 1], range(n // 2))):
	n //= 2
	a = a[:n]
print(n)


def issymmetric(n, mat):
	if n % 2:
		return False
	else:
		return mat[:n // 2] == mat[n // 2:][::-1]
(n, m) = map(int, input().split())
mat = []
for i in range(n):
	mat.append(list(map(int, input().split())))
while issymmetric(n, mat):
	mat = mat[:n // 2]
	n //= 2
print(n)


(n, m) = [int(i) for i in input().split()]
l = []
for i in range(n):
	l.append(input().strip())
while len(l) % 2 == 0:
	mirror = True
	for i in range(len(l) // 2):
		if l[i] != l[len(l) - 1 - i]:
			mirror = False
			break
	if mirror:
		l = l[:len(l) // 2]
	else:
		break
print(len(l))


import fileinput

def check_matrix(m):
	first_half = []
	second_half = []
	for i in range(len(m) // 2):
		first_half.append(m[i])
	for j in range(len(m), len(m) // 2, -1):
		second_half.append(m[j - 1])
	if first_half == second_half:
		return first_half
	else:
		return -1
(n, m) = map(int, input().split())
matrix = []
for arg in range(n):
	matrix.append(input().split())
if len(matrix) % 2 == 0:
	result = matrix
	num_rows = n
	while result != -1:
		result = check_matrix(result)
		if result != -1:
			num_rows = len(result)
	print(num_rows)
else:
	print(n)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
while n and n % 2 == 0 and (a[:n // 2] == a[n - 1:n // 2 - 1:-1]):
	n //= 2
print(n)