import math
n=int(input())
arr=[]
for i in range(n):
	x=input()
	arr.append(x)
stack=[]
c=0
nums=[]
for i in range(n):
	if len(stack)==0:
		stack.append(arr[i])
		c+=1
		continue
	else:
		if stack[-1]==arr[i]:
			c+=1
		else:
			nums.append(c)
			c=1
			stack.append(arr[i])
# print(c)
nums.append(c)
# print(nums)
gcc=n 
for i in range(len(nums)):
	gcc=math.gcd(gcc,nums[i])
print(gcc)