Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.

For each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.

Note, that if some day there are no opponents present, Arya still considers he beats all the present opponents.


-----Input-----

The first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively.

The i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.


-----Output-----

Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents.


-----Examples-----
Input
2 2
10
00

Output
2

Input
4 1
0100

Output
1

Input
4 5
1101
1111
0110
1011
1111

Output
2



-----Note-----

In the first and the second samples, Arya will beat all present opponents each of the d days.

In the third sample, Arya will beat his opponents on days 1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
(n, d) = map(int, input().split())
list1 = []
test = '1' * n
for i in range(0, d):
	s = input()
	if test == s:
		list1.append(0)
	else:
		list1.append(1)
max1 = 0
temp = 0
i = 0
for i in range(len(list1)):
	if list1[i] == 1:
		temp += 1
	else:
		temp = 0
	if temp > max1:
		max1 = temp
print(max1)


(n, d) = map(int, input().split())
ans = 0
cons = 0
for _ in range(d):
	s = input()
	if s == '1' * n:
		cons = 0
	else:
		cons += 1
		ans = max(ans, cons)
print(ans)


(n, d) = map(int, input().split())
(l, count) = ([], 0)
for i in range(d):
	k = set(list(input()))
	if '0' in k:
		count += 1
	else:
		l.append(count)
		count = 0
	l.append(count)
print(max(l))


a = []
s = []
d = 0
for i in range(int(input().split()[1])):
	a.append(input())
for i in a:
	if '0' in i:
		d += 1
	else:
		s.append(d)
		d = 0
s.append(d)
print(max(s))


(n, d) = map(int, input().split())
l = []
l1 = []
for i in range(d):
	s = input()
	l.append(s)
c = 0
for i in range(d):
	for j in range(n):
		if l[i][j] == '0':
			c += 1
			break
	else:
		l1.append(c)
		c = 0
if l1:
	print(max(max(l1), c))
else:
	print(c)


(n, d) = input().split()
flag = int(0)
s = []
c = int(0)
while int(d) > 0:
	arr = input()
	a = [int(x) for x in str(arr)]
	if flag == 1:
		s.append(c)
		c = 0
		flag = 0
	if a.count(0) != 0 and flag == 0:
		c = c + 1
		flag = 0
	else:
		flag = 1
	d = int(d) - 1
s.append(c)
print(max(s))


string = input()
numbers = string.split(' ')
n = int(numbers[0])
d = int(numbers[1])
streak = 0
streaks = []
for x in range(d):
	string = input()
	if '0' in string:
		streak += 1
	else:
		streaks.append(streak)
		streak = 0
streaks.append(streak)
print(max(streaks))


__author__ = 'artyom'

def main():
	(n, d) = read(3)
	mx = 0
	c = 0
	for i in range(d):
		s = read(0)
		if '0' in s:
			c += 1
		else:
			if c > mx:
				mx = c
			c = 0
	if c > mx:
		mx = c
	return mx

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


def does_arya_beat(s):
	for i in s:
		if i != '1':
			return True
	return False

def main_function():
	(n, d) = [int(i) for i in input().split(' ')]
	counts = []
	count = 0
	for i in range(d):
		s = input()
		if does_arya_beat(s):
			count += 1
			if i == d - 1:
				counts.append(count)
		else:
			counts.append(count)
			count = 0
	return max(counts)
print(main_function())


(a, b) = map(int, input().split())
c = 0
m = c
for i in range(b):
	x = input()
	if '0' in x:
		c += 1
		m = max(m, c)
	else:
		c = 0
print(m)


(n, d) = map(int, input().split())
l = []
ss = '1' * n
for i in range(d):
	s = input()
	if s == ss:
		l += [i]
if len(l) == 0:
	print(d)
elif len(l) == 1:
	print(max(d - 1 - l[0], l[0]))
else:
	a = l[1] - l[0]
	for i in range(1, len(l) - 1):
		if l[i + 1] - l[i] > a:
			a = l[i + 1] - l[i]
	print(max(a - 1, l[0], d - 1 - l[len(l) - 1]))


(n, m) = map(int, input().split())
(t, i) = (0, 0)
for v in range(m):
	p = input()
	if '0' in p:
		i += 1
		if i > t:
			t = i
	else:
		i = 0
print(t)


(m, n) = input().split()
b = w = 0
for i in range(int(n)):
	if '0' in input():
		w += 1
	else:
		w = 0
	b = max(w, b)
print(b)


(n, d) = map(int, input().split())
count = 0
l = []
x = []
for i in range(d):
	s = input()
	if '0' in s:
		l.append(1)
	else:
		l.append(0)
for i in range(len(l)):
	if l[i] == 1:
		count += 1
		if i == len(l) - 1:
			x.append(count)
	elif l[i] == 0 or i == len(l) - 1:
		x.append(count)
		count = 0
print(max(x))


(n, d) = map(int, input().split())
mx = 0
cnt = 0
for i in range(d):
	x = input()
	if x.count('0') > 0:
		cnt += 1
	else:
		mx = max(mx, cnt)
		cnt = 0
mx = max(mx, cnt)
print(mx)


(n, d) = map(int, input().split())
arr = [1] * d
for i in range(d):
	arr[i] = input().count('1') == n
arr += [1]
ans = 0
ind = -1
for i in range(d + 1):
	if arr[i]:
		ans = max(ans, i - ind - 1)
		ind = i
print(ans)


n = list(map(int, input().split()))
s = 0
lst = []
for i in range(n[1]):
	n1 = input()
	if '0' in n1:
		s = s + 1
	else:
		lst.append(s)
		s = 0
lst.append(s)
print(max(lst))


(n, d) = map(int, input().split())
(cnt, res) = (0, 0)
for i in range(d):
	cnt = cnt + 1 if '0' in input() else 0
	res = max(res, cnt)
print(res)


(d, n) = (int(z) for z in input().split())
mat = []
for i in range(n):
	mat.append([int(z) for z in input()])
mm = 0
cu = 0
for i in range(n):
	if sum([mat[i][z] for z in range(d)]) == d:
		cu = 0
	else:
		cu += 1
		if cu > mm:
			mm = cu
print(mm)


def check(a):
	res = 0
	for i in range(len(a)):
		if a[i] == '1':
			res += 1
	return res != len(a)
a = list(input().split(' '))
a = list((int(x) for x in a))
n = a[0]
d = a[1]
res = loc_res = 0
for i in range(d):
	a = input()
	if check(a):
		loc_res += 1
	else:
		res = max(loc_res, res)
		loc_res = 0
res = max(loc_res, res)
print(res)


from sys import stdin, stdout
(e, n) = map(int, stdin.readline().split())
cnt = 0
ans = 0
for i in range(n):
	s = stdin.readline().rstrip()
	if s.count('1') != e:
		cnt += 1
	else:
		cnt = 0
	ans = max(ans, cnt)
stdout.write(str(ans))


(n, d) = list(map(int, input().split()))
m = k = 0
for i in range(d):
	s = input()
	if '0' in s:
		k += 1
	else:
		if k > m:
			m = k
		k = 0
if k > m:
	m = k
print(m)


import math
from typing import Iterable, List

def solve(arr: Iterable[str]) -> int:
	res = [0]
	for v in arr:
		count_of_0 = v.count('0')
		if count_of_0:
			res[-1] += 1
		else:
			res.append(0)
	return max(res)

def main():
	(n, d) = map(int, input().split(' '))
	arr = []
	for i in range(d):
		x = input()
		arr.append(x)
	print(solve(arr))
main()


(n, d) = input().split()
(n, d) = (int(n), int(d))
present = ''.join(['1'] * n)
max = 0
win = 0
for i in range(d):
	day = input()
	if day != present:
		win = win + 1
	else:
		if win > max:
			max = win
		win = 0
if win > max:
	max = win
print(max)


(a, b) = map(int, input().split())
tmp = 0
counter = 0
for i in range(b):
	list1 = list(map(int, input()))
	if list1.count(1) < a:
		counter += 1
		if counter > tmp:
			tmp = counter
	else:
		counter = 0
print(tmp)


(n, d) = map(int, input().split())
a = [input() for i in range(d)]
p = 0
cur_ans = 0
ans = 0
for j in range(d):
	for k in range(n):
		if a[j][k] == '1':
			p += 1
	if p < n:
		cur_ans += 1
		ans = max(ans, cur_ans)
	else:
		cur_ans = 0
	p = 0
ans = max(ans, cur_ans)
print(ans)


(n, d) = list(map(int, input().split()))
all_present = '1' * n
long_seq = 0
seq = 0
for _ in range(d):
	if input() == all_present:
		if seq > long_seq:
			long_seq = seq
		seq = 0
	else:
		seq += 1
if seq > long_seq:
	long_seq = seq
print(long_seq)


(gandaho, ruz) = map(int, input().split())
zero = 0
maximum = 0
for i in range(ruz):
	io = input()
	if io.count('0') > 0:
		zero += 1
		maximum = max(maximum, zero)
	else:
		zero = 0
print(maximum)


import sys
if False:
	input = open('arya.txt', 'r')
else:
	input = sys.stdin
given = input.readline().split()
n = int(given[0])
d = int(given[1])
winDays = []
count = 1
counts = []
for i in range(1, d + 1):
	attendance = input.readline().strip()
	if attendance.count('1') != n:
		winDays.append(i)
if len(winDays) > 0:
	for num in winDays:
		if num + 1 in winDays:
			count = count + 1
		else:
			counts.append(count)
			count = 1
	counts = sorted(counts)
	counts = counts[::-1]
	print(counts[0])
else:
	print(0)


import sys, math
(n, m) = map(int, input().split())
z = [0] * m
for i in range(m):
	s = input()
	if '0' in s:
		z[i] = 1
z.append(0)
max_ = 0
now = 0
for i in range(m + 1):
	if z[i] == 0:
		max_ = max(max_, now)
		now = 0
	else:
		now += 1
print(max_)


(n, d) = map(int, input().split())
c = 0
ans = 0
for i in range(d):
	s = input()
	if '0' in s:
		c += 1
	else:
		c = 0
	if c > ans:
		ans = c
print(ans)


(n, d) = list(map(int, input().split()))
max_stroke = 0
current_stroke = 0
for i in range(d):
	schedule = input()
	if '0' in schedule:
		current_stroke += 1
		if current_stroke > max_stroke:
			max_stroke = current_stroke
	else:
		current_stroke = 0
print(max_stroke)


(opp, day) = map(int, input().split())
cnt = 0
x = []
for _ in range(day):
	if input().count('0') > 0:
		cnt += 1
	else:
		x.append(cnt)
		cnt = 0
x.append(cnt)
print(max(x))


a = str(input(''))
b = a.split(' ')
n = int(b[0])
m = int(b[1])
y = ''
result = 0
for i in range(n):
	y = y + '1'
consec = 0
k = 0
z = 0
r = -1
for i in range(m):
	x = str(input(''))
	if x < y:
		consec = consec + 1
		if result < consec:
			result = max(consec, r)
	elif x == y:
		if result < consec:
			result = max(consec, r)
		consec = 0
print(result)


(N, M) = map(int, input().split())
presence = []
for _ in range(M):
	presence.append(input())
max_day = 0
days = 0
for p in presence:
	if '0' in p:
		days += 1
	else:
		if max_day < days:
			max_day = days
		days = 0
if days > max_day:
	max_day = days
print(max_day)


(n, d) = map(int, input().split())
a = []
for _ in ' ' * d:
	a.append(input())
cnt = 0
mx = 0
for i in a:
	if i == '1' * n:
		mx = max(mx, cnt)
		cnt = 0
	else:
		cnt += 1
print(max(mx, cnt))


(n, d) = list((int(a) for a in input().split()))
(ms, s) = (0, 0)
for _ in range(d):
	p = sum(list((int(a) for a in input())))
	if p == n:
		if s > ms:
			ms = s
		s = 0
	else:
		s += 1
print(max(s, ms))


(n, m) = map(int, input().split(' '))
b = [bool(False) for i in range(m)]
for i in range(m):
	s = str(input())
	if '0' in s:
		b[i] = True
res = 0
i = 0
while i < m:
	(j, sum) = (i, 0)
	while j < m and b[j]:
		sum += 1
		j += 1
	res = max(res, sum)
	i = j + 1
print(res)


def I():
	return map(int, input().split())
(_, d) = I()
(tmp, ans) = (0, 0)
for i in range(d):
	if '0' not in input():
		tmp = 0
	else:
		tmp += 1
		ans = max(tmp, ans)
print(ans)


from collections import Counter

def func():
	l = []
	(x, y) = map(int, input().split())
	for i in range(y):
		l.append(input())
	ma = 0
	ans = -1
	for i in l:
		if i.count('1') != len(i):
			ma += 1
		else:
			if ma > ans:
				ans = ma
			ma = 0
	if ma > ans:
		ans = ma
	print(ans)
t = 1
for i in range(t):
	func()


(n, d) = map(int, input().split())
consecutiveDays = 0
currentMax = 0
for item in range(d):
	current = input()
	if '0' in current:
		currentMax += 1
		consecutiveDays = max(consecutiveDays, currentMax)
	else:
		currentMax = 0
print(consecutiveDays)


(a, b) = input().split()
(a, b) = (int(a), int(b))
k = 0
m = 0
for i in range(b):
	c = input()
	if c.count('0') > 0:
		k += 1
	else:
		if m < k:
			m = k
		k = 0
if m < k:
	m = k
print(m)


(n, k) = map(int, input().split())
w = 0
j = 0
for i in range(k):
	t = str(input())
	y = t.count('1')
	if y == n:
		w = 0
	else:
		w += 1
		if w > j:
			j = w
print(j)


(n, m) = map(int, input().split())
a = []
for i in range(m):
	a.append(input())
m1 = 0
m2 = 0
for i in range(m):
	k = 0
	for j in range(n):
		if a[i][j] == '0':
			break
		k += 1
	if k == n:
		if m2 > m1:
			m1 = m2
		m2 = 0
	else:
		m2 += 1
if m2 > m1:
	m1 = m2
print(m1)


(n, m) = map(int, input().split())
l = [0]
c = 0
for i in range(m):
	s = input()
	if '0' in s:
		c = c + 1
		l.append(c)
	else:
		c = 0
print(max(l))


import sys
(n, d) = list(map(int, sys.stdin.readline().split()))
lst = []
day = []
for i in range(d):
	lst.append(input())
for i in range(d):
	for j in range(n):
		if lst[i][j] == '0':
			day.append(1)
			break
	else:
		day.append(0)
cnt = 0
maxx = 0
for i in day:
	if i == 1:
		cnt += 1
		if cnt > maxx:
			maxx = cnt
	else:
		cnt = 0
print(maxx)


__author__ = 'Dilshod'
(n, d) = map(int, input().split())
cnt = 0
mx = -float('inf')
for i in range(d):
	d = input()
	if '0' in d:
		cnt += 1
	else:
		mx = max(mx, cnt)
		cnt = 0
mx = max(mx, cnt)
print(mx)


(n, d) = map(int, input().split())
maxCount = 0
curentCount = 0
for i in range(d):
	string = input()
	if string.__contains__('0'):
		curentCount += 1
	else:
		if curentCount > maxCount:
			maxCount = curentCount
		curentCount = 0
if curentCount > maxCount:
	maxCount = curentCount
print(maxCount)


def isAllOnes(st):
	for ch in st:
		if ch == '0':
			return False
	return True
(n, d) = (int(j) for j in input().split())
currun = 0
maxrun = 0
for i in range(d):
	nextone = input()
	if isAllOnes(nextone):
		currun = 0
	else:
		currun += 1
		if currun > maxrun:
			maxrun = currun
print(maxrun)


(n, d) = map(int, input().split())
l = []
for i in range(d):
	s = input()
	z = s.count('0')
	l.append(z)
c = 0
ans = 0
for i in range(len(l)):
	if l[i] > 0:
		c += 1
	else:
		c = 0
	ans = max(ans, c)
print(ans)


s = [int(n) for n in input().split()]
z = []
for n in range(s[1]):
	a = [int(n) for n in input()]
	if a.count(0) != 0:
		z.append(0)
	else:
		z.append(1)
k = 0
v = [[] for n in range(z.count(1) + 1)]
d = []
for n in range(len(z)):
	if z[n] == 0:
		v[k].append(n)
	else:
		k += 1
m = 0
for n in range(len(v)):
	if len(v[n]) > m:
		m = len(v[n])
	else:
		m = m
print(m)


(n, d) = [int(i) for i in input().split()]
day = ''
(k, m) = (0, 0)
for i in range(d):
	day = input()
	if day.find('0') != -1:
		k += 1
	else:
		if m < k:
			m = k
		k = 0
if m > k:
	print(m)
else:
	print(k)


inp = input().split()
(n, d) = (int(inp[0]), int(inp[1]))
a = ''
for i in range(n):
	a += '1'
(ans, cnt) = (0, 0)
for i in range(d):
	st = input()
	if st == a:
		ans = max(ans, cnt)
		cnt = 0
	else:
		cnt += 1
print(max(ans, cnt))


s = input()
(n, m) = s.split(' ')
n = int(n)
m = int(m)
L = []
for i in range(m):
	L.append(input())
ans = 0
res = 0
tmp = 0
for i in range(m):
	tmp = L[i].count('1')
	if tmp is n:
		ans = max(ans, res)
		res = 0
	else:
		res += 1
		ans = max(res, ans)
print(ans)


(a, b) = list(map(int, input().split()))
c = 0
m = 0
for _ in range(b):
	l = input()
	o = l.count('0')
	if o >= 1:
		c += 1
	else:
		c = 0
	if c > m:
		m = c
print(m)


(n, d) = [int(i) for i in input().split()]
res = 0
tmp = 0
for i in range(d):
	s = input()
	if '0' in s:
		tmp += 1
		if tmp > res:
			res = tmp
	else:
		tmp = 0
print(res)


(n, d) = map(int, input().split())
max = 0
count = 0
for i in range(int(d)):
	k = input()
	t = 0
	for j in range(int(n)):
		t += int(k[j])
	if t < n:
		count += 1
	if max < count:
		max = count
	if t == n:
		count = 0
print(max)


(m, n) = map(int, input().split())
k = 0
x = 0
while n > 0:
	l = input()
	if l.count('1') != len(l):
		x = x + 1
	else:
		k = max(k, x)
		x = 0
	n = n - 1
k = max(k, x)
print(k)


def solve():
	(n, d) = map(int, input().split())
	ans = curr = 0
	for _ in range(d):
		ln = input()
		if '0' in ln:
			curr += 1
		else:
			ans = max(ans, curr)
			curr = 0
	return max(ans, curr)
print(solve())


(n, m) = list(map(int, input().split()))
l = []
cnt = 0
for i in range(m):
	s = input()
	x = s.count('1')
	y = s.count('0')
	if y:
		cnt += 1
	else:
		l.append(cnt)
		cnt = 0
l.append(cnt)
print(max(l))


(cur, seqlen) = (0, 0)
for i in range(int(input().split(' ')[1])):
	if '0' in input():
		cur += 1
	else:
		cur = 0
	if cur > seqlen:
		seqlen = cur
print(seqlen)


(n, k) = map(int, input().split())
t = 0
res = 0
for i in range(k):
	s = input()
	if s != '1' * n:
		t += 1
	else:
		res = max(res, t)
		t = 0
print(max(res, t))


(n, d) = map(int, input().split())
s = '1' * n
c = 0
m = 0
for u in range(d):
	l = input()
	if l == s:
		c = 0
	else:
		c = c + 1
		if m < c:
			m = c
print(m)


(o, d) = map(int, input().split())
sol = []
flag = 0
count = 0
for i in range(d):
	s = input()
	if '0' in s:
		count += 1
	else:
		flag = 1
		sol.append(count)
		count = 0
if flag == 0:
	print(count)
else:
	sol.append(count)
	print(max(sol))


(n, d) = map(int, input().split())
matrix = [input() for i in range(d)]
sums = [matrix[i].count('0') for i in range(d)]
mx = 0
now = 0
for i in range(d):
	if sums[i] > 0:
		now += 1
	else:
		mx = max(now, mx)
		now = 0
print(max(mx, now))


(n, d) = [int(x) for x in input().split(' ')]
cnt = 0
l = 0
for i in range(d):
	c = input()
	if '0' in c:
		cnt += 1
	else:
		if cnt > l:
			l = cnt
		cnt = 0
if cnt > l:
	l = cnt
print(l)


(n, d) = list(map(int, input().split()))
answer = 0
cnt = 0
for i in range(d):
	s = input()
	if s.find('0') != -1:
		cnt += 1
	else:
		answer = max(answer, cnt)
		cnt = 0
print(max(answer, cnt))


[n, d] = [int(x) for x in input().split()]
count = 0
finalcount = 0
t = []
for i in range(d):
	if '0' in input():
		count += 1
	else:
		count = 0
	t.append(count)
print(max(t))


(n, d) = input().split()
(n, d) = (int(n), int(d))
presence = []
for i in range(0, d):
	presence.append(input())
k = 0
maximo = 0
for i in range(0, d):
	if '0' in presence[i]:
		k += 1
	else:
		k = 0
	if k > maximo:
		maximo = k
print(maximo)


a = input().split()
(n, d) = (int(a[0]), int(a[1]))
count = 0
check = True
list = []
for i in range(d):
	s = input()
	for j in range(n):
		if s[j] == '0':
			count += 1
			check = False
			break
	if check:
		list.append(count)
		count = 0
	check = True
list.append(count)
print(max(list))


(n, d) = map(int, input().split())
c = 0
e = []
r = [0]
for i in range(d):
	s = input()
	e.append(s)
for i in e:
	if i.count('0') > 0:
		c += 1
		r.append(c)
	else:
		c = 0
print(max(r))


(n, d) = map(int, input().split())
max_ans = 0
seq = 0
for i in range(d):
	val_str = input()
	if '0' in val_str:
		seq += 1
	else:
		seq = 0
	max_ans = max(seq, max_ans)
print(max_ans)


(n, d) = list(map(int, input().split()))
lista = []
ans = 0
maxi = 0
for i in range(d):
	lista.append(input())
for i in range(d):
	if '0' in lista[i]:
		ans += 1
	else:
		if maxi < ans:
			maxi = ans
		ans = 0
if maxi < ans:
	maxi = ans
print(maxi)


(n, d) = map(int, input().split())
c = [input() for _ in range(d)]
r = 0
x = 0
for v in c:
	if '0' in v:
		x += 1
		r = max(r, x)
	else:
		x = 0
print(r)


x = [int(i) for i in input().split()]
n = x[0]
d = x[1]
consecutive = 0
max_consecutive = -1
for i in range(d):
	s = input()
	if '0' in s:
		consecutive += 1
	elif '0' not in s:
		consecutive = 0
	max_consecutive = max(max_consecutive, consecutive)
print(max_consecutive)


(n, a) = input().split(' ')
d1 = int(a)
ans = 0
ma = 0
for i in range(d1):
	a = input()
	c0 = a.count('0')
	c1 = a.count('1')
	if c0 > 0:
		ans += 1
		ma = max(ma, ans)
	else:
		ans = 0
print(ma)


n = list(map(int, input().split()))
count = 0
arr = []
for i in range(n[1]):
	z = input()
	if '0' in z:
		count += 1
	else:
		arr.append(count)
		count = 0
arr.append(count)
print(max(arr))


def longest_non_max_subarray(numbers, target):
	max_length = 0
	current_length = 0
	for number in numbers:
		if number < target:
			current_length += 1
		else:
			current_length = 0
		if current_length > max_length:
			max_length = current_length
	return max_length
(target, n) = map(int, input().split())
numbers = []
for _ in range(n):
	current_sum = 0
	word = input()
	for letter in word:
		if letter == '1':
			current_sum += 1
	numbers.append(current_sum)
print(longest_non_max_subarray(numbers, target))


def check(x):
	for i in x:
		if i == '0':
			return 1
	return 0
(n, k) = map(int, input().split())
kol = 0
MAX = 0
for i in range(0, k):
	x = input()
	if check(x):
		kol += 1
		MAX = max(MAX, kol)
	else:
		kol = 0
print(MAX)


(n, d) = map(int, input().split())
a = list()
for i in range(d):
	a.append(input())
k = h = x = 0
for i in range(d):
	for j in range(n):
		if a[i][j] == '0':
			k += 1
			h = 1
			break
	if x < k:
		x = k
	if h:
		h = 0
	else:
		k = 0
print(x)


(a, b) = map(int, input().split())
c = 0
n = []
for i in range(b):
	l = list(input())
	if '0' in l:
		c += 1
	else:
		c = 0
	n.append(c)
print(max(n))


(n, d) = map(int, input().strip().split())
res = 0
cur = 0
for _ in range(d):
	if n == input().strip().count('1'):
		res = max(res, cur)
		cur = 0
	else:
		cur += 1
print(max(res, cur))


(n, d) = [int(x) for x in input().split()]
max_vic = 0
vic = 0
test = '1' * n
for i in range(d):
	if input() == test:
		max_vic = max(vic, max_vic)
		vic = 0
	else:
		vic += 1
max_vic = max(vic, max_vic)
print(max_vic)


(x, y) = map(int, input().split())
maxim = 0
c = []
for i in range(y):
	c.append(input())
count = 0
flag = 0
for i in range(len(c)):
	if '0' in c[i]:
		count += 1
		flag = 0
	else:
		maxim = max(count, maxim)
		count = 0
		flag = 1
if flag == 1:
	print(maxim)
else:
	maxim = max(maxim, count)
	print(maxim)


(n, d) = map(int, input().split())
l = []
for i in range(d):
	a = list(input())
	l.append(a)
r = []
for i in range(len(l)):
	b = l[i]
	if l[i].count('1') < n:
		r.append(1)
	else:
		r.append(0)
c = 0
r1 = []
for i in range(len(r)):
	if r[i] == 1:
		c = c + 1
	else:
		c = 0
	r1.append(c)
print(max(r1))


from math import ceil

def main():
	(n, m) = [int(v) for v in input().split()]
	vals = [input() for v in range(m)]
	vals.append('1' * n)
	m = 0
	l = -1
	for (i, v) in enumerate(vals):
		if v == '1' * n:
			m = max(i - l - 1, m)
			l = i
	print(m)
main()


(n, d) = input().split()
n = int(n)
d = int(d)
l = []
c = 0
for z in range(d):
	s = input()
	s = list(s)
	if s.count('0') > 0:
		c += 1
	else:
		l.append(c)
		c = 0
l.append(c)
print(max(l))


import math

def f():
	(n, d) = map(int, input().split())
	consutive = 0
	max = 0
	for _ in range(d):
		string = input()
		if '0' in string:
			consutive += 1
		else:
			consutive = 0
		if consutive > max:
			max = consutive
	print(max)
f()


(n, d) = (int(_) for _ in input().split())
maxx = 0
cur = 0
for i in range(d):
	s = input()
	if s == '1' * n:
		maxx = max(maxx, cur)
		cur = 0
	else:
		cur += 1
print(max(maxx, cur))


(n, d) = map(int, input().split())
ans = ''
for i in range(d):
	a = input().find('0')
	if a != -1:
		ans = ans + '1'
	else:
		ans = ans + '0'
ans = ans.split('0')
ans = list(filter(None, ans))
if len(ans) == 0:
	print(0)
else:
	print(max(list(map(len, ans))))


(n, d) = map(int, input().split())
c = 0
l = []
for i in range(d):
	l.append(input())
emp = []
for i in range(d):
	if l[i].count('0') == 0:
		emp.append(c)
		c = 0
	else:
		c += 1
emp.append(c)
print(max(emp))


__author__ = 'aste'

def main():
	(n, d) = [int(i) for i in input().split()]
	count = 0
	res = 0
	for i in range(0, d):
		opponents = input()
		if opponents.count('1') == n:
			count = 0
		else:
			count += 1
			res = max(res, count)
	print(res)
main()


(a, b) = map(int, input().split())
d = int(0)
e = []
for _ in range(b):
	c = str(input())
	if c.find('0') != -1:
		d = d + 1
	else:
		e.append(d)
		d = 0
e.append(d)
print(max(e))


(n, d) = map(int, input().split())
max_p = 0
now_p = 0
for i in range(d):
	s = str(input())
	if s != '1' * n:
		now_p += 1
		max_p = max(max_p, now_p)
	else:
		max_p = max(max_p, now_p)
		now_p = 0
print(max_p)


mw = 0
w = 0
(n, d) = map(int, input().split())
for _ in range(d):
	if '0' in input():
		w += 1
		mw = max(w, mw)
	else:
		w = 0
print(mw)


(n, d) = map(int, input().split())
l = []
count = 0
for _ in range(d):
	s = input()
	if s != '1' * n:
		count += 1
	else:
		count = 0
	l.append(count)
print(max(l))


(n, d) = map(int, input().split())
a = [0] * d
for i in range(d):
	s = input()
	for j in range(n):
		a[i] += int(s[j])
ans = 0
curr = 0
for i in a:
	if i == n:
		ans = max(ans, curr)
		curr = 0
	else:
		curr += 1
print(max(curr, ans))


(n, m) = map(int, input().split())
cnt = 0
mx = 0
for i in range(m):
	x = sum([int(digit) for digit in str(input())])
	if x < n:
		cnt += 1
	mx = max(mx, cnt)
	if x == n:
		cnt = 0
print(mx)


(n, m) = input().split()
(n, m) = (int(n), int(m))
ans = []
for i in range(m):
	d = input()
	count = 0
	for j in d:
		if j == '1':
			count += 1
	if count < n:
		ans.append(1)
	else:
		ans.append(0)
s = 0
ma = 0
for i in ans:
	if i == 1:
		s += 1
	else:
		s = 0
	ma = max(ma, s)
print(ma)


(n, d) = (int(x) for x in input().split())
k = ans = 0
for x in range(d):
	if input() == '1' * n:
		ans = max(k, ans)
		k = 0
	else:
		k += 1
ans = max(k, ans)
print(ans)


(n, d) = map(int, input().split())
co = 0
m = 0
for _ in range(d):
	s = input()
	if '0' in s:
		co += 1
	if '0' not in s:
		m = max(m, co)
		co = 0
	m = max(m, co)
print(m)


(n, d) = map(int, input().split())
m = 0
c = 0
for i in range(d):
	checker = False
	s = input()
	for j in s:
		if '0' == j:
			checker = True
			break
	if checker:
		c += 1
	else:
		if m < c:
			m = c
		c = 0
print(max(m, c))


(c, r) = map(int, input().split())
(ans, cnt) = (0, 0)
for i in range(r):
	str = input()
	beat = False
	for j in str:
		if j != '1':
			beat = True
	if beat == True:
		cnt += 1
	else:
		ans = max(ans, cnt)
		cnt = 0
ans = max(ans, cnt)
print(ans)


(n, k) = map(int, input().split())
a = [0]
count = 0
for i in range(k):
	c = list(input())
	if '0' in c:
		count += 1
		a.append(count)
	else:
		count = 0
print(max(a))


f = lambda : map(int, input().split())
(n, d) = f()
ind = []
c = cnt = 0
for i in range(d):
	s = input()
	if s != '1' * n:
		cnt += 1
	else:
		c = max(c, cnt)
		cnt = 0
	c = max(c, cnt)
print(c)


def chk(n):
	s = list(n)
	if '0' in s:
		return True
	return False
(n, d) = map(int, input().split())
(c, m) = (0, 0)
for _ in range(d):
	if chk(input()) == True:
		c += 1
		m = max(m, c)
	else:
		c = 0
print(m)


data = [int(info) for info in input().split()]
current_max = 0
our_max = 0
for i in range(0, data[1]):
	presence = [int(info) for info in input()]
	if len(set(presence)) == 1 and presence[0] == 1:
		if current_max > our_max:
			our_max = current_max
		current_max = 0
	else:
		current_max += 1
if current_max > our_max:
	print(current_max)
else:
	print(our_max)


(n, d) = map(int, input().split())
(cur_len, max_len) = (0, 0)
for i in range(d):
	x = input()
	if len(x) == x.count('1'):
		if cur_len > max_len:
			max_len = cur_len
		cur_len = 0
	else:
		cur_len += 1
	if i == d - 1:
		max_len = max(cur_len, max_len)
print(max_len)


response = input()
(enemies, days) = response.split()
enemies = int(enemies)
days = int(days)
check = 2 ** enemies - 1
shedule = []
while days > 0:
	response = input()
	shedule.append(int(response, base=2))
	days -= 1
wins = 0
maximum = 0
for item in shedule:
	if check != item:
		wins += 1
	else:
		maximum = wins if wins > maximum else maximum
		wins = 0
maximum = wins if wins > maximum else maximum
print(maximum)


(n, a) = map(int, input().split())
ar = []
c = 0
m = 0
for i in range(a):
	ar.append(input())
for i in ar:
	if '0' in i:
		c += 1
		m = max(c, m)
	else:
		c = 0
print(m)


(n, d) = map(int, input().split())
j = 0
z = []
for i in range(d):
	l = str(input())
	if l.count('1') != n:
		j += 1
		z.append(j)
	else:
		j = 0
		z.append(j)
print(max(z))


string = input()
(n, d) = string.split()
n = int(n)
d = int(d)
wins = 0
maxim = wins
for i in range(d):
	x = input()
	if '0' in x:
		wins += 1
	else:
		wins = 0
	if wins > maxim:
		maxim = wins
print(maxim)


(a, b) = map(int, input().split())
c = 0
l = []
flag = 0
for i in range(b):
	s = input()
	if '0' in s:
		c = c + 1
		l.append(c)
	else:
		c = 0
if len(l) == 0:
	print(0)
else:
	print(max(l))


(n, d) = map(int, input().split())
(ans, cur) = (0, 0)
for i in range(d):
	if all((c == '1' for c in list(input()))):
		cur = 0
	else:
		cur += 1
	ans = max(ans, cur)
print(ans)


(n, d) = map(int, input().split())
strings = [input() for i in range(d)]
(counter, max1) = (0, 0)
for i in strings:
	if i == '1' * n:
		if counter > max1:
			max1 = counter
		counter = 0
	else:
		counter += 1
if counter > max1:
	max1 = counter
print(max1)


(n, d) = map(int, input().split())
c = int(0)
m = int(0)
for i in range(d):
	l = input()
	if l.find('0') != -1:
		c += 1
	else:
		if c > m:
			m = c
		c = 0
if c > m:
	m = c
print(m)


(enemies_count, days_count) = [int(num) for num in input().split()]
win_days_count = 0
win_days_count_max = 0
for i in range(days_count):
	enemies_in_school = input()
	if '0' in enemies_in_school:
		win_days_count += 1
	else:
		win_days_count = 0
	if win_days_count > win_days_count_max:
		win_days_count_max = win_days_count
print(win_days_count_max)


(o, d) = map(int, input().split())
u = 0
res = 0
for i in range(d):
	a = int(input())
	if a * 9 + 1 == 10 ** o:
		if u < res:
			u = res
		res = 0
	elif a * 9 + 1 < 10 ** o:
		res += 1
		if u < res:
			u = res
print(u)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(m, n) = q()
cm = 0
c = 0
for _ in range(n):
	a = input()
	if not a.count('0'):
		c = 0
	else:
		c += 1
	if cm < c:
		cm = c
print(cm)


(n, d) = map(int, input().split())
streak = 0
maximum = 0
for day in range(d):
	c = input()
	if c != '1' * n:
		streak += 1
		maximum = max(maximum, streak)
	else:
		streak = 0
print(maximum)


(n, d) = map(int, input().split())
km = 0
k = 0
for i in range(d):
	s = input()
	if s.find('0') == -1:
		km = max(km, k)
		k = 0
	else:
		k += 1
km = max(km, k)
print(km)


(n, d) = map(int, input().split())
ryl = []
ryl.append(-1)
for i in range(d):
	p = 1
	new_day = input()
	for j in range(n):
		if new_day[j] == '0':
			p = 0
	if p == 1:
		ryl.append(i)
ryl.append(d)
maxx = 0
for i in range(1, len(ryl)):
	a = ryl[i] - ryl[i - 1] - 1
	if a > maxx:
		maxx = a
print(maxx)


(n, d) = map(int, input().split())
win = k = 0
for i in range(d):
	n = input()
	if '0' in n:
		win += 1
	else:
		win = 0
	k = max(k, win)
print(k)


(n, m) = [int(x) for x in input().split()]
d = []
c = 0
for i in range(m):
	s = input()
	x = s.count('1')
	y = s.count('0')
	if y >= 1:
		c += 1
	elif y == 0:
		d.append(c)
		c = 0
d.append(c)
print(max(d))


(n, d) = list(map(int, input().split()))
(best, cur) = (0, 0)
for i in range(d):
	day = list(set(input()))
	if day != ['1']:
		cur += 1
	else:
		cur = 0
	best = max(best, cur)
print(best)


(n, d) = map(int, input().split())
cnt = 0
res = 0
for i in range(d):
	s = input()
	bad = True
	for j in range(n):
		if s[j] != '1':
			bad = False
	if not bad:
		cnt += 1
	else:
		cnt = 0
	res = max(res, cnt)
print(res)


(n, d) = map(int, input().split())
ans = ['0' if '0' in input() else '1' for i in range(d)]
print(max(map(len, ''.join(ans).split('1'))))


aps = 0
pas = 0
(n, d) = map(int, input().split())
for i in range(d):
	a = input()
	if a.count('1') < len(a):
		aps += 1
	else:
		if aps > pas:
			pas = aps
		aps = 0
if aps > pas:
	pas = aps
print(pas)


l = list(map(int, input().split()))
n = 0
l1 = []
for _ in range(l[1]):
	st = list(input())
	np = st.count('1')
	if np < l[0]:
		n += 1
	else:
		l1.append(n)
		n = 0
l1.append(n)
print(max(l1))


(a, b) = input().split(' ')
b = int(b)
l = []
vic = 0
consec = 0
while b > 0:
	l.append(str(input()))
	b -= 1
for ele in l:
	if str(ele).find('0') != -1:
		vic += 1
	else:
		vic = 0
	if vic > consec:
		consec = vic
print(consec)


(n, m) = [int(i) for i in input().split()]
(ans, cur) = (0, 0)
for i in range(m):
	s = input()
	if s.find('0') != -1:
		cur += 1
		ans = max(ans, cur)
	else:
		cur = 0
print(ans)


(n, d) = map(int, input().split())
(result, current) = (0, 0)
for _ in range(d):
	tmp = input()
	if any([x != '1' for x in tmp]):
		current += 1
	else:
		result = max([result, current])
		current = 0
result = max([result, current])
print(result)


def is_win_day(str):
	for el in str:
		if el == '0':
			return True
	return False
(num_oponents, days) = input().split(' ')
num_oponents = int(num_oponents)
days = int(days)
counter = 0
win_cons_days = 0
for i in range(days):
	str = input()
	if is_win_day(str):
		counter = counter + 1
	else:
		counter = 0
	win_cons_days = max(win_cons_days, counter)
print(win_cons_days)


read = lambda : map(int, input().split())
(n, d) = read()
a = [list(map(int, input())) for i in range(d)]
ans = 0
d = 0
for i in a:
	if sum(i) < n:
		d += 1
	else:
		ans = max(ans, d)
		d = 0
ans = max(ans, d)
print(ans)


(n, d) = map(int, input().split())
(a, b) = (0, 0)
for i in range(d):
	c = input()
	if c == '1' * n:
		a = 0
	else:
		a += 1
	b = max(b, a)
print(b)


(n, d) = [int(i) for i in input().split()]
cur = 0
maxim = 0
for i in range(d):
	if '0' in input():
		cur += 1
		if cur > maxim:
			maxim = cur
	else:
		cur = 0
print(maxim)


(n, d) = map(int, input().split())
A = [0 for i in range(d)]
(mx, mxt) = (0, 0)
for i in range(d):
	s = input()
	if '0' in s:
		mxt += 1
	else:
		mxt = 0
	mx = max(mx, mxt)
print(mx)


s = input()
a = s.split()
max = 0
flag = 0
num = 0
for i in range(int(a[1])):
	c = input()
	for j in range(len(c)):
		if c[j] == '0':
			flag = 1
	if flag == 1:
		num = num + 1
	elif num > max:
		max = num
		num = 0
	else:
		num = 0
		flag = 0
	flag = 0
if num < max:
	print(max)
else:
	print(num)


import sys
(k, n) = map(int, input().split())
days = 0
mx = 0
for i in range(n):
	a = input()
	x = a.count('1')
	if x < k:
		days += 1
		if days > mx:
			mx = days
	else:
		days = 0
print(mx)


(a, b) = map(int, input().split())
cnt = 0
x = []
y = 0
for i in range(b):
	x.append(input())
for i in range(b):
	if x[i].find('0') != -1:
		cnt += 1
	else:
		y = max(y, cnt)
		cnt = 0
print(max(y, cnt))


n = [int(x) for x in input().split()]
count = 0
countmax = 0
for i in range(0, n[1]):
	q = input()
	check = 1
	for j in range(0, n[0]):
		if q[j] == '0':
			check = 0
			break
	if check == 0:
		count += 1
	else:
		count = 0
	if count > countmax:
		countmax = count
print(countmax)


(n, d) = map(int, input().split())
ans = 0
k = 0
for i in range(d):
	s = str(input())
	if s == '1' * n:
		ans = max(ans, k)
		k = 0
	else:
		k += 1
print(max(ans, k))


(n, m) = map(int, input().split())
sz = 0
msz = 0
ones = '1' * n
for _ in range(m):
	if input() == ones:
		sz = 0
	else:
		sz += 1
		msz = max(sz, msz)
print(msz)


(n, m) = map(int, input().split())
rez = 0
cur = 0
for i in range(m):
	text = input()
	if '0' in text:
		cur += 1
	else:
		cur = 0
	if cur > rez:
		rez = cur
print(rez)


(n, k) = map(int, input().split())
result = elem = temp = ans = 0
for i in range(k):
	s = input()
	s = list(s)
	result = all((elem == '1' for elem in s))
	if result == 0:
		temp += 1
	else:
		temp = 0
	if temp > ans:
		ans = temp
	s = ''
print(ans)


(n, d) = map(int, input().split())
l = []
for i in range(d):
	s = input()
	if '0' in s:
		l.append(1)
	else:
		l.append(0)
if 1 not in l:
	print(0)
elif len(l) == 1:
	print(l[0])
else:
	(c, ans) = (1, 0)
	for i in range(1, d):
		if l[i] == l[i - 1] == 1:
			c += 1
		else:
			ans = max(ans, c)
			c = 1
	if c:
		ans = max(ans, c)
	print(ans)


(a, b) = map(int, input().split())
t = [0]
s = 0
for i in range(b):
	x = input()
	if '0' in x:
		s = s + 1
		t.append(s)
	else:
		s = 0
print(max(t))


(N, n) = list(map(int, input().split()))
mas = []
for i in range(n):
	a = input()
	if '0' in a:
		mas.append(1)
	else:
		mas.append(0)
max = 1
M = 0
if len(mas) == 1 and mas[0] == 1:
	print(1)
else:
	for j in range(1, n):
		if mas[j] == mas[j - 1] and mas[j] == 1:
			max += 1
			if max > M:
				M = max
		else:
			max = 1
	if 1 in mas and M == 0:
		print(1)
	else:
		print(M)


(n, d) = map(int, input().split())
(list, temp) = ([], [])
for i in range(d):
	list.append(input())
i = 0
while i < d:
	count = 0
	while i < d and list[i].count('0') > 0:
		count += 1
		i += 1
	i += 1
	temp.append(count)
print(max(temp))


(n, d) = map(int, input().split())
current_s = ''
for i in range(n):
	current_s += '1'
current_streak = 0
max_streak = -1
for i in range(d):
	current_day = input()
	if current_day != current_s:
		current_streak += 1
	else:
		max_streak = max(current_streak, max_streak)
		current_streak = 0
max_streak = max(max_streak, current_streak)
print(max_streak)


(n, d) = map(int, input().split())
(o, cont) = (0, 0)
for i in range(d):
	s = input()
	if '0' in s:
		cont += 1
	else:
		o = max(o, cont)
		cont = 0
print(max(o, cont))


(n, d) = (int(i) for i in input().split())
c = 0
m = 0
for i in range(d):
	if input().count('1') != n:
		c += 1
		m = max(c, m)
	else:
		c = 0
print(m)


(a, b) = map(int, input().split())
k = []
l = []
r = []
z = 0
q = 0
for i in range(b):
	k.append(input())
	l.append(k[i].find('0'))
for i in range(len(l)):
	while z == 0 and q + i != len(l):
		if l[q + i] == -1:
			z = 1
		else:
			q += 1
	r.append(q)
	z = 0
	q = 0
print(max(r))


(n, d) = map(int, input().split())
l = []
while d:
	l.append(input())
	d = d - 1
(c, m) = (0, 0)
for i in range(len(l)):
	if '0' in l[i]:
		c += 1
	else:
		c = 0
	m = max(c, m)
print(m)


(k, v) = map(int, input().split())
str = '1' * k
res = []
repeat = 0
for i in range(v):
	line = input()
	if line != str:
		repeat += 1
	else:
		res.append(repeat)
		repeat = 0
res.append(repeat)
print(max(res))


(n, d) = map(int, input().split())
p = []
c = 0
for i in range(d):
	a = str(input())
	o = a.count('1')
	if o < n:
		c += 1
		p.append(c)
	else:
		p.append(c)
		c = 0
p.sort()
print(p[-1])


(n, d) = map(int, input().split(' '))
(count, mx) = (0, 0)
for i in range(d):
	a = input().replace('0', '')
	if len(a) != n:
		count += 1
	else:
		if count > mx:
			mx = count
		count = 0
if count > mx:
	mx = count
	count = 0
print(mx)


(n, d) = map(int, input().split())
maxKolDay = 0
kolDay = 0
for i in range(d):
	a = input()
	if '0' in a:
		kolDay += 1
	else:
		maxKolDay = max(maxKolDay, kolDay)
		kolDay = 0
maxKolDay = max(maxKolDay, kolDay)
print(maxKolDay)


(n, d) = map(int, input().split())
streak = 0
maxi = -1
for i in range(d):
	x = input()
	if x != '1' * n:
		streak += 1
	else:
		if streak > maxi:
			maxi = streak
		streak = 0
if streak > maxi:
	maxi = streak
print(maxi)


def p1():
	(n, m) = [float(i) for i in input().split('e')]
	if n * 10 ** m == int(n * 10 ** m):
		print(int(n * 10 ** m))
	else:
		print(n * 10 ** m)

def p2():
	n = int(input())
	l = [int(i) for i in input().split()]
	ans = 'YES'
	if n == 1:
		if l.count(0) == 1:
			ans = 'NO'
	elif l.count(0) != 1:
		ans = 'NO'
	print(ans)

def p3():
	(n, m) = [int(i) for i in input().split()]
	k = 0
	m2 = 0
	for j in range(m):
		a = input()
		if a.count('1') == len(a):
			m2 = max(m2, k)
			k = 0
		else:
			k = k + 1
	m2 = max(m2, k)
	print(m2)

def p4():
	(n, m) = [int(i) for i in input().split()]
	t = 0
	l = m
	for i in range(n):
		a = input().split()
		b = int(a[1])
		a = a[0]
		if a == '+':
			l = l + b
		elif l >= b:
			l = l - b
		else:
			t = t + 1
	print(l, t)

def p5():
	(n, m) = [int(i) for i in input().split()]
	l = []
	v = []
	g = []
	for i in range(n):
		s = input()
		l.append(s)
		v.append(s.count('*'))
	for i in range(m):
		t = 0
		for j in range(n):
			if l[j][i] == '*':
				t = t + 1
		g.append(t)
	ans = 'NO'
	c = sum(v)
	for i in range(n):
		for j in range(m):
			t = v[i] + g[j]
			if l[i][j] == '*':
				t = t - 1
			if t == c:
				ans = 'YES'
				(x, y) = (i + 1, j + 1)
				break
		if ans == 'YES':
			break
	print(ans)
	if ans == 'YES':
		print(x, y)
p3()


(n, d) = map(int, input().split())
a = [list(input()) for i in range(d)]
count = 0
max = 0
for i in range(d):
	if sum(list(map(int, a[i]))) == n:
		count = 0
	else:
		count += 1
	if count > max:
		max = count
print(max)


import sys
import os
numbers = list(map(int, input().split()))
n = numbers[0]
d = numbers[1]
maxC = 0
C = 0
flag = 0
for i in range(0, d):
	str = input()
	flag = 0
	for j in range(0, n):
		if str[j] == '0':
			flag = 1
			break
	if flag == 0:
		maxC = max(maxC, C)
		C = 0
	else:
		C = C + 1
maxC = max(maxC, C)
print(maxC)


(n, d) = map(int, input().split())
c = 0
maxc = 0
while d > 0:
	x = input()
	if x.count('1') == len(x):
		maxc = max(maxc, c)
		c = 0
	else:
		c += 1
	d -= 1
maxc = max(maxc, c)
print(maxc)


import itertools
(n, d) = [int(i) for i in input().split()]
beat = []
for i in range(d):
	beat.append(not all([[False, True][int(x)] for x in input()]))
print(max([len(list(g)) for (_, g) in filter(lambda i: i[0], itertools.groupby(beat))], default=0))


(n, d) = map(int, input().split())
l = []
for i in range(d):
	s = input()
	l.append(s)
cnt = 0
cnt1 = 0
z = []
for j in range(len(l)):
	if '0' in l[j]:
		cnt += 1
	else:
		z.append(cnt)
		cnt = 0
if len(z) == 0:
	print(cnt)
else:
	print(max(max(z), cnt))


(n, d) = map(int, input().split())
a = [input() == '1' * n for _ in range(d)]
ans = 0
for i in range(d):
	if not a[i]:
		j = i
		while j < d and (not a[j]):
			j += 1
		ans = max(ans, j - i)
print(ans)


st = [int(i) for i in input().split(' ')]
a = st[0]
b = st[1]
ar = []
k = 0
kmax = 0
for i in range(b):
	n = str(input())
	if n == '1' * a:
		ar.append(0)
	else:
		ar.append(1)
for i in range(len(ar)):
	if ar[i] == 1:
		k += 1
		if k > kmax:
			kmax = k
	else:
		k = 0
print(kmax)


(n, d) = input().split()
n = int(n)
d = int(d)
w = ' '
cwin = []
win = []
for i in range(d):
	w = str(input())
	l = list(w)
	if l.count('1') != n:
		win.append(True)
	else:
		win.append(False)
k = 0
for elem in win:
	if elem == True:
		k += 1
	else:
		cwin.append(k)
		k = 0
cwin.append(k)
cwin.sort()
print(cwin[-1])


(n, d) = map(int, input().split())
check = '1' * n
ans = 0
cur = 0
for i in range(d):
	s = input()
	if s != check:
		cur += 1
		ans = max(ans, cur)
	else:
		cur = 0
print(ans)


(n, d) = map(int, input().split())
ans = 0
c = 0
for _ in range(d):
	if input().count('0'):
		c += 1
		ans = max(c, ans)
	else:
		c = 0
print(ans)


(n, d) = map(int, input().split())
count = 0
max_count = 0
for i in range(d):
	day = list(input())
	if day.count('1') == n:
		count = 0
	else:
		count += 1
	max_count = max(count, max_count)
print(max_count)


(n, d) = map(int, input().split())
m = 0
c = 0
for _ in range(d):
	f = 0
	x = input()
	l = len(x)
	for i in range(l):
		if x[i] == '0':
			f = 1
			break
	if f == 1:
		c += 1
		if c > m:
			m = c
	else:
		c = 0
print(m)


(n, d) = map(int, input().split())
c = 0
f = 0
for i in range(d):
	l = list(map(int, input()))
	b = list(set(l))
	if len(b) > 1:
		c += 1
	elif len(b) == 1 and b[0] == 0:
		c += 1
	else:
		c = 0
	f = max(f, c)
print(f)


(n, d) = map(int, input().split())
a = []
for i in range(d):
	a.append(input())
cur = 0
mx = 0
for i in range(d):
	ok = True
	for j in range(n):
		if a[i][j] == '0':
			ok = False
			break
	if not ok:
		cur += 1
		mx = max(mx, cur)
	else:
		cur = 0
print(mx)


(n, m) = map(int, input().split())
L = ''.join([str(int('0' in input())) for k in range(m)])
L += '0'
print(max(*[k.count('1') for k in L.split('0')]))


(n, d) = list(map(int, input().split()))
max = 0
seq = 0
for i in range(d):
	if '0' in set(input()):
		seq += 1
	else:
		if seq > max:
			max = seq
		seq = 0
if seq > max:
	max = seq
print(max)


from collections import *
from math import *
from itertools import *
import os
import sys
from io import BytesIO, IOBase

def main():
	(n, d) = map(int, input().split())
	res = 0
	ans = 0
	for i in range(d):
		if '0' in input():
			res += 1
		else:
			ans = max(ans, res)
			res = 0
	ans = max(ans, res)
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = input().split()
k = int(a[0])
n = int(a[1])
max = 0
x = 0
for i in range(n):
	a = input()
	done = False
	for j in a:
		if j == '0':
			done = True
			break
	if done:
		x += 1
	else:
		if x > max:
			max = x
		x = 0
if x > max:
	max = x
print(max)


def main():
	(d, n) = input().split()
	(d, n) = (int(d), int(n))
	max_win_streak = 0
	curr_win_streak = 0
	for i in range(n):
		enemies_num = str(input()).count('1')
		if enemies_num < d:
			curr_win_streak += 1
		else:
			max_win_streak = max(max_win_streak, curr_win_streak)
			curr_win_streak = 0
	max_win_streak = max(max_win_streak, curr_win_streak)
	print(max_win_streak)
main()


def enemies(days):
	max_interval = 0
	current = 0
	for day in days:
		current = current + 1 if '0' in day else 0
		max_interval = max(current, max_interval)
	return max_interval
(n, k) = map(int, input().split())
list_of_enemies = []
for i in range(k):
	list_of_enemies.append(input())
print(enemies(list_of_enemies))


a = [int(x) for x in input().split()]
consecutive = 0
best = 0
for i in range(0, a[1]):
	opponents = str(input())
	if opponents.find('0') == -1:
		consecutive = 0
	else:
		consecutive += 1
		if consecutive > best:
			best = consecutive
print(best)


(n, d) = map(int, input().split())
s = ''
ss = ''
a = d * [0]
for i in range(n):
	ss += '1'
for i in range(d):
	s = str(input())
	if s == ss:
		a[i] = 0
	else:
		a[i] = 1
cnt = 0
MaxCnt = 0
for i in range(d):
	if a[i] == 1:
		cnt += 1
	else:
		cnt = 0
	MaxCnt = max(MaxCnt, cnt)
print(MaxCnt)


import math, sys, re
(rs, ri, rai) = (input, lambda : int(input()), lambda : list(map(int, input().split())))
(n, d) = rai()
t = '1' * n
(m, c) = (0, 0)
for l in sys.stdin.read().splitlines():
	if l == t:
		c = 0
	else:
		c += 1
	m = max(m, c)
print(m)


(n, d) = map(int, input().split())
days = [True] * d
consecutive = 0
max = 0
for x in range(d):
	line = input()
	for c in line:
		if c == '0':
			days[x] = False
for x in days:
	if x:
		if consecutive > max:
			max = consecutive
		consecutive = 0
	else:
		consecutive += 1
if consecutive > max:
	max = consecutive
print(max)


(_, d) = input().split(' ')
d = int(d)
current = 0
previous = 0
for i in range(d):
	s = input()
	if '0' in s:
		current += 1
	elif current > previous:
		previous = current
		current = 0
	else:
		current = 0
print(max(previous, current))


(n, d) = list(map(int, input().split()))
lst = []
count = 0
for i in range(d):
	days = input()
	if '0' in days:
		count += 1
		if i == d - 1:
			lst.append(count)
	else:
		lst.append(count)
		count = 0
print(max(lst))


(a, b) = map(int, input().split())
list1 = [[list(map(int, input()))] for i in range(b)]
temp = 0
ans = 0
for i in list1:
	if str(i).count('1') == a:
		temp = 0
	else:
		temp += str(i).count('1') < a
	if ans < temp:
		ans = temp
print(ans)


(n, m) = map(int, input().split())
(last, cnt, ans) = (-100500, 0, 0)
for i in range(m):
	if sum(list(map(int, input()))) != n:
		if last + 1 == i:
			cnt += 1
		else:
			cnt = 1
		last = i
	ans = max(ans, cnt)
print(ans)


import sys
import math
import bisect

def main():
	(n, d) = map(int, input().split())
	B = [0] * d
	for i in range(d):
		A = list((int(a) for a in input()))
		if sum(A) < n:
			B[i] = 1
	max_val = 0
	val = 0
	for i in range(d):
		if B[i] == 1:
			val += 1
		else:
			val = 0
		max_val = max(max_val, val)
	print(max_val)
main()


a = input().split(' ')
n = int(a[0])
d = int(a[1])
df = set()
c = 0
a = ['' for i in range(d)]
for i in range(d):
	a[i] = input()
	if a[i].count('1') < n:
		c += 1
	elif a[i].count('1') == n:
		df.add(c)
		c = 0
df.add(c)
print(max(df))


(n, m) = map(int, input().split())
cnt = 0
x = 0
for i in range(m):
	s = input()
	if '0' in s:
		cnt += 1
		x = max(x, cnt)
	else:
		cnt = 0
print(x)


l = [int(x) for x in input().split()]
n = l[0]
k = l[1]
l = []
count = 0
for i in range(k):
	s = input()
	if '0' in s:
		count += 1
	else:
		l.append(count)
		count = 0
l.append(count)
print(max(l))


d = str(input()).split(' ')
x = 0
y = 0
b = []
for i in range(0, int(d[1])):
	a = list(input())
	for j in range(0, len(a)):
		if a[j] == '1':
			x += 1
	if x != int(d[0]):
		y += 1
		b.append(y)
	elif x == int(d[0]):
		y = 0
	x = 0
for i in b:
	if i > x:
		x = i
print(x)


(n, d) = map(int, input().split())
(c, p) = (0, -1)
for i in range(d):
	s = input()
	if s.count('0') > 0:
		c = max(c, i - p)
	else:
		p = i
print(c)


(n, d) = map(int, input().split())
arr = []
for i in range(d):
	s = input()
	arr.append(s)
c = 0
m = 0
for i in range(len(arr)):
	if arr[i] == '1' * n:
		c = 0
		continue
	else:
		c += 1
		m = max(m, c)
print(m)


read = lambda : map(int, input().split())
(n, d) = read()
a = [input() for i in range(d)]
ans = cur = 0
for i in a:
	if i.count('1') < n:
		cur += 1
	else:
		cur = 0
	ans = max(ans, cur)
print(ans)


(n, d) = map(int, input().split())
res = 0
arr = []
for i in range(d):
	a = input()
	if a.count('1') < n:
		res += 1
	else:
		arr.append(res)
		res = 0
else:
	arr.append(res)
if len(arr) == 0:
	print(0)
else:
	print(max(arr))


inputz = input().split()
n = int(inputz[0])
d = int(inputz[1])
con = 0
win = 0
for i in range(d):
	temp = input()
	if '0' in temp:
		win += 1
	else:
		if win > con:
			con = win
		win = 0
if win > con:
	con = win
print(con)


(r, x) = (0, 0)
for _ in [0] * int(input().split()[1]):
	x = [0, x + 1]['0' in input()]
	r = max(r, x)
print(r)


(n, d) = map(int, input().split())
r = 0
m = 0
for _ in range(d):
	s = input()
	if '0' in s:
		r = r + 1
	else:
		m = max(r, m)
		r = 0
	m = max(r, m)
print(m)


(n, d) = [int(x) for x in input().split()]
current = 0
max_seq = 0
for i in range(d):
	day_schedule = input()
	if '0' in day_schedule or day_schedule == '':
		current += 1
		if max_seq < current:
			max_seq = current
	else:
		current = 0
print(max_seq)


(n, d) = map(int, input().split())
c = 0
ans = 0
for i in range(d):
	s = input()
	f = 0
	for j in range(len(s)):
		if s[j] == '0':
			f = 1
	if f == 1:
		c += 1
	else:
		ans = max(ans, c)
		c = 0
ans = max(ans, c)
print(ans)


nd = list(map(int, input().split()))
school = []
maximum = 0
temp = 0
accept = 1
for k in range(nd[1]):
	school.append(list(map(int, input())))
	accept = 1
	for i in range(nd[0]):
		if school[k][i] == 0:
			temp += 1
			accept = 0
			break
	if accept == 1:
		accept = 0
		maximum = max(maximum, temp)
		temp = 0
maximum = max(maximum, temp)
print(maximum)


(a, b) = [int(i) for i in input().split()]
g = b * [0]
d = 0
t = 0
h = 0
c = '0'
for i in range(b):
	g[i] = input()
for i in range(h, b):
	if i % 2 == 0:
		if c in g[i]:
			t = t + 1
		else:
			t = 0
		if t > d:
			d = t
	elif i % 2 != 0:
		if c in g[i]:
			t = t + 1
		else:
			t = 0
		if t > d:
			d = t
print(d)


(n, d) = map(int, input().split())
f = 0
k = 0
for _ in range(d):
	e = input()
	if '0' in e:
		f += 1
	else:
		f = 0
	k = max(k, f)
print(k)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, D) = map(int, input().split())
ans = 0
p = 0
for i in range(D):
	s = input()
	if all((x == '1' for x in s)):
		ans = max(ans, i - p)
		p = i + 1
ans = max(ans, D - p)
print(ans)


(n, d) = map(int, input().split())
maxd = 0
day = 0
for i in range(d):
	enemy = input()
	if '0' in enemy:
		day += 1
	else:
		if day > maxd:
			maxd = day
		day = 0
if day > maxd:
	maxd = day
print(maxd)


(n, m) = map(int, input().split())
nums = []
for i in range(m):
	x = input()
	if '0' in x:
		nums.append(1)
	else:
		nums.append(0)
count_ = []
for i in range(0, len(nums)):
	if nums[i] == 0:
		continue
	else:
		temp = 0
		for j in range(i, len(nums)):
			if nums[j] == 1:
				temp += 1
			else:
				break
		count_.append(temp)
if len(count_) == 0:
	print(0)
else:
	print(max(count_))


(a, b) = map(int, input().split())
count = 0
temp = 0
for i in range(b):
	n = input()
	if '0' in n:
		count += 1
		temp = max(temp, count)
	else:
		count = 0
print(temp)


from sys import stdin, stdout, stderr

def main():
	(n, d) = map(int, stdin.readline().split())
	cur = 0
	ans = 0
	for i in range(d):
		today = stdin.readline()
		cnt = 0
		for x in today:
			cnt += x == '1'
		if cnt < n:
			cur += 1
		else:
			cur = 0
		ans = max(ans, cur)
	stdout.write(str(ans))
main()


(a, b) = map(int, input().split())
c = 0
e = []
for i in range(b):
	d = input()
	if '0' in d:
		c += 1
	if '0' not in d:
		e.append(c)
		c = 0
e.append(c)
e.sort()
print(e[-1])


ans = 0
timesDefeating = 0
(numberOfOpponents, numberOfDays) = list(map(int, input().split()))
for _ in range(numberOfDays):
	opponents = input()
	if '0' in opponents:
		timesDefeating += 1
		ans = max(timesDefeating, ans)
	else:
		timesDefeating = 0
print(ans)


(n, m) = map(int, input().split())
c = 0
cons = []
for _ in range(m):
	s = input()
	if '0' in s:
		c += 1
	else:
		cons.append(c)
		c = 0
cons.append(c)
print(max(cons))


[n, d] = [int(x) for x in input().split()]
L = [-1]
for i in range(d):
	s = input()
	if '0' not in s:
		L.append(i)
L.append(d)
print(max([L[i] - L[i - 1] - 1 for i in range(1, len(L))]) if len(L) != 1 else d)


(n, t) = map(int, input().split())
(m, max1) = (0, 0)
for j in range(t):
	s = input()
	c = s.count('0')
	if c > 0:
		m = m + 1
		max1 = max(m, max1)
	else:
		m = 0
print(max1)


(op, n) = input().split(' ')
arr = ''
for i in range(int(n)):
	s = input()
	if '0' in s:
		arr = arr + '1'
	else:
		arr = arr + '@'
l = arr.split(str('@'))
sol = 0
for p in l:
	sol = max(sol, len(p))
print(sol)


(n, d) = map(int, input().split())
ans = []
s = 0
for i in range(d):
	l = list(input())
	if '0' in l:
		s += 1
		ans.append(s)
	else:
		s = 0
		ans.append(s)
print(max(ans))


raw_input = input()
list_input = list(map(int, raw_input.split()))
n = list_input[0]
d = list_input[1]
max_combo = 0
combo = 0
for _ in range(d):
	schedule = input()
	count = 0
	for appear in schedule:
		if appear == '0':
			combo += 1
			break
		count += 1
		if count == n:
			combo = 0
	if combo > max_combo:
		max_combo = combo
print(max_combo)


winning_streak = 0
biggest_winning_streak = 0
for i in range(int(input().split(' ')[1])):
	if '0' in input():
		winning_streak += 1
		if winning_streak > biggest_winning_streak:
			biggest_winning_streak = winning_streak
	else:
		winning_streak = 0
print(biggest_winning_streak)


(n, k) = map(int, input().split())
c = 0
t = 0
from functools import reduce
import operator as op
for i in range(k):
	s = list(map(int, input()))
	temp = reduce(op.mul, s)
	if temp:
		c = max(t, c)
		t = 0
	else:
		t += 1
print(max(c, t))


line1 = input().split()
n = int(line1[0])
d = int(line1[1])
days = []
for i in range(d):
	thisday = input()
	for char in thisday:
		if char == '0':
			days.append(0)
			break
	if len(days) <= i:
		days.append(1)
best = 0
curr = 0
for day in days:
	if day == 0:
		curr += 1
		best = max(best, curr)
	else:
		curr = 0
print(best)


(n, d) = [int(elem) for elem in input().split(' ')]
time_table = list()
for i in range(d):
	time_table.append(input())
(max_seq, curr_seq) = (0, 0)
all_of_them = True
for i in range(d):
	all_of_them = True
	for j in range(n):
		if time_table[i][j] == '0':
			all_of_them = False
			break
	if all_of_them == False:
		curr_seq += 1
	else:
		if max_seq < curr_seq:
			max_seq = curr_seq
		curr_seq = 0
if max_seq < curr_seq:
	max_seq = curr_seq
print(max_seq)


s = input()
L = s.split()
n = int(L[0])
d = int(L[1])
L = []
for x in range(d):
	s = input()
	L.append(s)
ans = 0
ct = 0
for i in range(d):
	s = 0
	for j in range(n):
		if L[i][j] == '1':
			s += 1
	if s < n:
		ct += 1
		ans = max(ans, ct)
	else:
		ct = 0
print(ans)


x = input().split()
l = int(x[0])
d = int(x[1])
maxx = [0] * d
it = 0
for i in range(d):
	x = input()
	for i in range(l):
		if x[i] == '0':
			maxx[it] = maxx[it] + 1
			break
	else:
		it += 1
print(max(maxx))


(n, d) = map(int, input().split())
brr = []
count = 0
max = 0
while d != 0:
	s = input()
	li = list(s)
	if li.count('0') >= 1:
		count += 1
	else:
		count = 0
	if count != 0:
		if max < count:
			max = count
	d = d - 1
print(max)


def answer():
	z = [int(x) for x in input().split()]
	n = z[0]
	d = z[1]
	ans = 0
	temp = 0
	while d:
		a = sum([int(x) for x in list(input())])
		if a < n:
			temp += 1
			if temp > ans:
				ans = temp
		else:
			if temp > ans:
				ans = temp
			temp = 0
		d -= 1
	print(ans)
answer()


(n, d) = map(int, input().split())
a = d * [0]
for i in range(0, d):
	t = input()
	if t.count('1') == n:
		a[i] = 0
	else:
		a[i] = 1
max = 0
ans = 0
for i in range(0, d):
	if a[i] == 1:
		ans = ans + 1
	else:
		ans = 0
	if ans > max:
		max = ans
print(max)


(enem, days) = map(int, input().split())
max_count = 0
new_count = 0
for i in range(days):
	string = input()
	if string.count('1') < enem:
		new_count += 1
	else:
		if new_count > max_count:
			max_count = new_count
		new_count = 0
if new_count > max_count:
	max_count = new_count
print(max_count)


(n, d) = map(int, input().split())
days = []
for line in range(d):
	day = input()
	days.append(day)
count = 0
maxcount = 0
for day in days:
	win = False
	for enemy in range(n):
		if int(day[enemy]) == 0:
			win = True
			continue
	if win:
		count += 1
	else:
		if count > maxcount:
			maxcount = count
		count = 0
if count > maxcount:
	maxcount = count
print(maxcount)


(n, d) = [int(x) for x in input().split()]
a = 0
consecutiveDay = 0
maxDay = 0
for i in range(0, n):
	a += 10 ** i
for i in range(0, d):
	present = int(input())
	if present < a:
		consecutiveDay += 1
		if maxDay < consecutiveDay:
			maxDay = consecutiveDay
	else:
		consecutiveDay = 0
print(maxDay)


(n, d) = map(int, input().split())
m = 0
c = 0
for i in range(d):
	s = input()
	o = s.count('1')
	if len(s) == o:
		if c > m:
			m = c
		c = 0
	else:
		c = c + 1
if c > m:
	m = c
print(m)


n = input()
l = n.split()
d = int(l[1])
op = int(l[0])
mx = 0
lst = mx
for ui in range(0, d):
	line = input()
	if '0' in line:
		mx = mx + 1
		if mx >= lst:
			lst = mx
	else:
		mx = 0
print(lst)


(n, d) = list(map(int, input().split()))
arr = []

def summa(stri):
	gg = 0
	for i in stri:
		if i == '1':
			gg += 1
	return gg
for i in range(d):
	arr.append(input())
arr2 = [0] * d
for i in range(d):
	if summa(arr[i]) < n and i != 0:
		arr2[i] = arr2[i - 1] + 1
	elif i == 0 and summa(arr[i]) < n:
		arr2[i] = 1
print(max(arr2))


(n, d) = map(int, input().split())
days = []
for _ in range(d):
	days.append(list(input()))
max_win = 0
wins = 0
for day in days:
	if day != ['1'] * n:
		wins += 1
		if wins > max_win:
			max_win = wins
	else:
		wins = 0
print(max_win)


def main():
	(n, d) = [int(x) for x in input().split()]
	m = [input() for _ in range(d)]
	cnt = 0
	mx = 0
	for x in m:
		if all((y == '1' for y in x)):
			mx = max(mx, cnt)
			cnt = 0
		else:
			cnt += 1
	print(max(mx, cnt))
main()


(_, d) = (int(x) for x in input().split())
curr_win_streak = 0
max_win_streak = 0
for _ in range(d):
	if '0' in input():
		curr_win_streak += 1
	else:
		curr_win_streak = 0
	max_win_streak = max(max_win_streak, curr_win_streak)
print(max_win_streak)


[n, d] = list(map(int, input().split()))
res = 0
cur = 0
for i in range(d):
	s = input()
	cnt = 0
	for j in range(len(s)):
		if s[j] == '1':
			cnt += 1
	if cnt == n:
		cur = 0
	else:
		cur += 1
	res = max(res, cur)
print(res)


(n, m) = map(int, input().split())
k = 0
a = []
for i in range(m):
	b = list(input())
	if '0' in b:
		k += 1
	else:
		a.append(k)
		k = 0
a.append(k)
print(max(a))


(n, d) = map(int, input().split())

def getMaxLength(arr, n):
	count = 0
	result = 0
	for i in range(0, n):
		if arr[i] == '0':
			count = 0
		else:
			count += 1
			result = max(result, count)
	return result
m = 0
l2 = []
while d > 0:
	l = list(input())
	if l.count('0') > 0:
		l2.append('1')
	else:
		l2.append('0')
	d = d - 1
m = getMaxLength(l2, len(l2))
print(m)


(s, n) = map(int, input().split())
ans = 0
c = 0
for i in range(n):
	st = input()
	if st.count('1') < s:
		c += 1
	else:
		ans = max(ans, c)
		c = 0
ans = max(ans, c)
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = [S() for _ in range(m)]
	c = 0
	r = 0
	for t in a:
		if '0' in t:
			c += 1
		else:
			if r < c:
				r = c
			c = 0
	if r < c:
		r = c
	return r
print(main())


(n, d) = map(int, input().split())
days = 0
max_days = 0
for i in range(d):
	if '0' in input():
		days += 1
		max_days = max(days, max_days)
	else:
		days = 0
print(max_days)


(n, d) = map(int, input().split())
ma = 0
k = 0
for i in range(d):
	s = input()
	if s.count('0') != 0:
		k = k + 1
		if k > ma:
			ma = k
	else:
		k = 0
print(ma)


(n, k) = list(map(int, input().split()))
pol = []
p = 0
for x in range(k):
	l = list(input())
	if l.count('0') >= 1:
		p += 1
	else:
		pol.append(p)
		p = 0
pol.append(p)
print(max(pol))


first = input()
x = first.split()
n = int(x[0])
d = int(x[1])
curr_days = 0
max_days = 0
for i in range(d):
	string = input()
	if '0' in string:
		curr_days += 1
		if curr_days > max_days:
			max_days = curr_days
	else:
		curr_days = 0
print(max_days)


(n, d) = [int(x) for x in input().split(' ')]
tt = n * '1'
t = 0
ans = 0
for i in range(0, d):
	xx = input()
	if xx == tt:
		t = 0
	else:
		t += 1
		ans = max(ans, t)
print(ans)


(n, d) = map(int, input().split())
s = [input() for _ in range(d)]
mx = 0
c = 0
for i in range(d):
	if s[i].count('1') != n:
		c += 1
	else:
		if mx < c:
			mx = c
		c = 0
if mx < c:
	mx = c
print(mx)


(n, d) = input().split()
(c, m) = (0, 0)
for i in range(int(d)):
	r = False
	for j in input():
		if j == '0':
			r = True
			break
	if r:
		c += 1
		if m < c:
			m = c
	else:
		c = 0
print(m)


(n, m) = map(int, input().split())
ans = cnt = 0
while m:
	s = input()
	if s.find('0') != -1:
		cnt += 1
	else:
		cnt = 0
	ans = max(ans, cnt)
	m -= 1
print(ans)


(n, d) = map(int, input().split())
c = 0
z = []
for i in range(d):
	l = list(input())
	if '0' in l:
		c += 1
	else:
		c = 0
	z.append(c)
print(max(z))


(nb_opps, nb_days) = [int(x) for x in input().split()]
arya_wins = 0
max_wins = 0
max_con_wins = 0
for _ in range(nb_days):
	opps = input()
	if '0' in opps:
		max_con_wins += 1
		max_wins = max(max_wins, max_con_wins)
	else:
		max_con_wins = 0
print(max_wins)


(n, d) = map(int, input().split())
counter = 0
m = 0
for i in range(d):
	a = input()
	if a.count('1') < n:
		counter += 1
		if counter > m:
			m = counter
	else:
		counter = 0
print(m)


days = []
m = 0
x = 0
for d in range(int(input().split()[1])):
	days.append(input())
for da in days:
	if da.count('1') == len(da):
		if x > m:
			m = x
		x = 0
	else:
		x += 1
print(max(m, x))


(n, d) = input().split()
n = int(n)
d = int(d)
a = []
for i in range(d):
	s = str(input())
	a.append(s)
att = 0
count = 0
out = 0
for j in range(d):
	att = 0
	for k in range(n):
		att += int(a[j][k])
	if att < n:
		count += 1
	else:
		out = max(count, out)
		count = 0
print(max(count, out))


import math
str_temp = input().split(' ')
(enem, days) = (int(str_temp[0]), int(str_temp[1]))
john_legend = 0
max_legend = 0
for i in range(days):
	str_temp = input()
	try:
		str_temp.index('0')
		john_legend += 1
	except ValueError:
		if max_legend < john_legend:
			max_legend = john_legend
		john_legend = 0
if max_legend < john_legend:
	max_legend = john_legend
print(max_legend)


(n, d) = map(int, input().split(' '))
ans = 0
temp = 0
for i in range(d):
	opp = list(map(int, list(input())))
	if n > sum(opp):
		temp += 1
		ans = max(ans, temp)
	else:
		temp = 0
print(ans)


(n, d) = [int(s) for s in input().split(' ')]
cd = 0
cd_max = 0
for i in range(d):
	s = input()
	if s.count('0') == 0:
		cd = 0
	else:
		cd += 1
		cd_max = max(cd, cd_max)
print(cd_max)


[n, d] = [int(x) for x in input().split()]
maxc = 0
c = 0
for i in range(0, d):
	s = input()
	d = 0
	for x in range(0, n):
		if s[x] == '0':
			d = 1
			break
	if d:
		c += 1
		if c > maxc:
			maxc = c
	else:
		c = 0
print(maxc)


(n, d) = map(int, input().split())
ch = []
c_ch = 0
for i in range(d):
	a = input()
	if '0' in a:
		c_ch += 1
	else:
		ch.append(c_ch)
		c_ch = 0
ch.append(c_ch)
print(max(ch))


(n, d) = input().split()
(n, d) = (int(n), int(d))
count = 0
Max = 0
for i in range(0, d):
	a = input()
	x = 0
	for j in a:
		if j == '0':
			x = 1
			break
	if x == 1:
		count = count + 1
		if count > Max:
			Max = count
	else:
		count = 0
print(Max)


a = input().split()
b = int(a[0])
c = int(a[1])
st = ''
li = []
for i in range(c):
	li.append(1 if b * '1' not in input().split() else 0)
c = 0
ma = 0
for i in li:
	if i == 0:
		c = 0
	else:
		c = c + 1
		ma = max(ma, c)
print(ma)


a = int(input().split()[1])
b = 0
c = 0
for i in range(a):
	if set(input()) != set('1'):
		b += 1
	else:
		c = max(b, c)
		b = 0
print(max(b, c))


def ii():
	return int(input())

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())
(a, b) = mi()
s = 0
ans = 0
for i in range(b):
	if '0' in input():
		s += 1
	else:
		s = 0
	ans = max(ans, s)
print(ans)


(n, d) = map(int, input().split())
maxi = cur = 0

def day(enemy):
	for i in enemy:
		if i == '0':
			return True
	return False
for _ in range(d):
	enemy = input()
	if day(enemy):
		cur += 1
	else:
		cur = 0
	if cur > maxi:
		maxi = cur
print(maxi)


def enemies(days):
	max_interval = 0
	current_interval = 0
	for day in days:
		enemies_win = True
		for enemy in day:
			if enemy == '0':
				current_interval += 1
				enemies_win = False
				max_interval = max(current_interval, max_interval)
				break
		if enemies_win:
			current_interval = 0
	return max_interval
(n, k) = map(int, input().split())
list_of_enemies = []
for i in range(k):
	list_of_enemies.append(input())
print(enemies(list_of_enemies))


a = input()
b = a.split()
a = int(b[0])
b = int(b[1])
maxx = 0
mas = 0
for i in range(b):
	k = 1
	r = str(input())
	for u in range(a):
		if r[u] == '0':
			k = 0
	if k == 0:
		mas = mas + 1
		if mas > maxx:
			maxx = mas
	else:
		mas = 0
print(maxx)


d = int(input().split()[1])
(a, c) = (0, 0)
for i in range(d):
	if '0' in input():
		c += 1
	else:
		c = 0
	a = max(a, c)
print(a)


s = list(map(int, input().split()))
n = s[1]
l = []
m = 0
cnt = 0
for i in range(n):
	s = input()
	if '0' in s:
		l.append(1)
	else:
		l.append(0)
for i in range(len(l)):
	if l[i] == 1:
		cnt = cnt + 1
	m = max(m, cnt)
	if l[i] == 0:
		cnt = 0
print(m)


(n, d) = map(int, input().split())
output = 0
t = 0
for i in range(d):
	l = input()
	if l.count('0') > 0:
		t += 1
	else:
		output = max(output, t)
		t = 0
print(max(output, t))


(n, d) = map(int, input().split())
num = 0
tmp = 0
for i in range(d):
	s = input()
	if '0' in s:
		tmp += 1
	else:
		num = max(tmp, num)
		tmp = 0
num = max(tmp, num)
print(num)


(n, d) = map(int, input().split())
ans = []
a = 0
for i in range(d):
	l = input()
	if '0' in l:
		a += 1
	else:
		ans.append(a)
		a = 0
	ans.append(a)
ans.sort(reverse=True)
print(ans[0])


(n, d) = map(int, input().split())
m = 0
s = -1
for i in range(0, d):
	x = input()
	x = list(x)
	if x.count('0') >= 1:
		m = m + 1
	else:
		s = max(s, m)
		m = 0
s = max(s, m)
print(s)


s = [int(x) for x in input().strip('\n').split(' ')]
n = s[0]
d = s[1]
p = 0
y = []
for i in range(0, d):
	if '0' in input().strip('\n'):
		p = p + 1
	else:
		y.append(p)
		p = 0
y.append(p)
print(max(y))


(x, n) = map(int, input().split())
c = 0
arr = []
for r in range(n):
	str = input()
	if '1' * x not in str:
		c = c + 1
	else:
		arr.append(c)
		c = 0
	if r == n - 1 and '1' * x not in str:
		arr.append(c)
sumday = 0
for v in arr:
	if sumday < v:
		sumday = v
print(sumday)


(n, m) = list(map(int, input().split()))
count = 0
st = []
p = []
for i in range(m):
	l = list(map(int, input()))
	p.append(l)
	if p[i].count(1) != n:
		count += 1
	else:
		count = 0
	st.append(count)
print(max(st))


(n, d) = map(int, input().split())
lines = [input() for _ in range(d)] + ['1']
acum = 0
best = 0
for line in lines:
	if '0' not in line:
		best = max(best, acum)
		acum = 0
	else:
		acum += 1
print(best)


(n, d) = map(int, input().split())
arr = []
for i in range(d):
	arr.append(input())

def check(s):
	fail = 0
	for x in s:
		if x == '0':
			fail = 1
	return fail
pres = 0
max = 0
for x in arr:
	if check(x):
		pres += 1
	else:
		if max < pres:
			max = pres
		pres = 0
if max < pres:
	max = pres
print(max)


(n, d) = map(int, input().split())
l = [0]
s = 0
for i in range(d):
	x = input()
	if ('0' in x) == True:
		s = s + 1
		l.append(s)
	else:
		s = 0
print(max(l))


(n, d) = map(int, input().split())
l = [sum(map(int, input())) for _ in range(d)]
ans = ma = 0
for i in range(d):
	if l[i] != n:
		ans += 1
	if ma < ans:
		ma = ans
	if l[i] == n:
		ans = 0
print(ma)


(anim, ds) = map(int, input().split())
pob = 0
sup = 0
dup = 0
for i in range(ds):
	c = input()
	for q in c:
		sup += int(q)
	if sup < anim:
		pob += 1
	else:
		pob = 0
	sup = 0
	dup = max(dup, pob)
print(dup)


(n, d) = list(map(int, input().split()))
hs = 0
cur = 0
for i in range(d):
	if '0' in list(input()):
		cur += 1
	else:
		cur = 0
	hs = max(cur, hs)
print(hs)


(o, n) = map(int, input().split())
w = []
t = []
r = []
for i in range(n):
	l = list(input())
	w.append(l)
for i in range(n):
	count = w[i].count('1')
	if count == o:
		t.append(i)
if len(t) >= 1:
	for i in range(1, len(t)):
		x = int(t[i]) - int(t[i - 1]) - 1
		r.append(x)
	r.append(int(t[0]))
	r.append(n - int(t[-1]) - 1)
	q = max(r)
	print(q)
else:
	print(n)


(n, d) = map(int, input().split())
count = 0
result = 0
for i in range(d):
	if input().count('1') == n:
		count = 0
	else:
		count += 1
	result = max(result, count)
print(result)


(n, d) = map(int, input().strip().split())
l = []
prev = 1
current_val = 0
max_val = 0
win_loss = 0
for i in range(d):
	val = input()
	if '0' in val:
		current_val += 1
	else:
		current_val = 0
	if current_val > max_val:
		max_val = current_val
print(max_val)


def enemies(lst):
	(k, result) = (0, 0)
	for elem in lst:
		if '0' in elem:
			k += 1
			result = max(result, k)
		else:
			k = 0
	return result
(n, d) = [int(i) for i in input().split()]
a = list()
for i in range(d):
	s = input()
	a.append(s)
print(enemies(a))


(o, d) = map(int, input().split())
m = 0
s = 0
for _ in range(d):
	c = input()
	if '0' in c:
		s += 1
	else:
		m = max(m, s)
		s = 0
m = max(m, s)
print(m)


(a, b) = map(int, input().split())
beat = []
for _ in [0] * b:
	k = input()
	if sum((1 for i in k if int(i) == 1)) == a:
		beat.append('0')
	else:
		beat.append('1')
print(max(map(len, ''.join(beat).split('0'))))


(n, m) = map(int, input().split())
checks = '1' * n
count = 0
result = 0
for _ in range(m):
	if input() == checks:
		result = max(result, count)
		count = 0
	else:
		count += 1
print(max(result, count))


(n, d) = map(int, input().split())
b = 0
v = ''
da = 1
for i in range(d):
	s = input()
	for i in s:
		b = 0
		if i == '0':
			b += 1
			break
		elif i != '0':
			b = 0
	v = v + str(b)
print(max(map(len, v.split('0'))))


(n, d) = map(int, input().split())
count = 0
sum = 0
for _ in range(d):
	opp = input()
	if '0' in opp:
		count += 1
		if count > sum:
			sum = count
	else:
		count = 0
print(sum)


(n, d) = str(input()).split()
n = int(n)
d = int(d)
tar = '1' * n
lv = 0
num = 0
for i in range(d):
	line = str(input())
	if line != tar:
		num += 1
	else:
		num = 0
	if num > lv:
		lv = num
print(lv)


a = list(map(int, input().split()))
i = 0
k = 0
z = 0
while i < a[1]:
	b = input()
	c = list(b)
	if '0' in c:
		k = k + 1
	else:
		k = 0
	if z < k:
		z = k
	i = i + 1
print(z)


(n, d) = map(int, input().split())
res = 0
c = 0
val = False
for i in range(d):
	s = input()
	if s.count('1') != n:
		c += 1
	else:
		if c > res:
			res = c
		c = 0
		val = True
if not val:
	print(c)
else:
	print(max(res, c))


import sys
(n, d) = map(int, input().split())
count = 0
mx = 0
for i in range(d):
	s = input()
	if s == '1' * n:
		mx = max(mx, count)
		count = 0
	else:
		count += 1
print(max(mx, count))


(n, d) = list(map(int, input().split()))
ans = 0
temp = 0
for i in range(d):
	ai = input()
	temp2 = 0
	for j in ai:
		if j == '0':
			temp += 1
			temp2 = 1
			break
	if temp2 == 0:
		temp = 0
	if temp > ans:
		ans = temp
print(ans)


(a, b) = map(int, input().split())
z = 0
m = 0
for i in range(b):
	s = str(input())
	if '0' in s:
		z = z + 1
	else:
		z = 0
	if m < z:
		m = z
print(m)


(d, n) = map(int, input().split())
print(max(map(lambda x: x.count('#'), ''.join(['#' + input() for _ in range(n)]).split('#' + '1' * d))))


temp = list(map(int, input().split()))
n = temp[0]
d = temp[1]
test_string = '1' * n
current = 0
result = 0
for i in range(d):
	temp = input()
	if temp == test_string:
		if current > result:
			result = current
		current = 0
	else:
		current += 1
if current > result:
	result = current
print(result)


from functools import reduce
(n, d) = map(int, input().split())
ans = 0
count = 0
for i in range(d):
	lst = list(map(int, input()))
	if reduce(lambda x, y: x and y, lst) == 0:
		count += 1
	else:
		ans = max(ans, count)
		count = 0
ans = max(ans, count)
print(ans)


(n, d) = [int(x) for x in input().split()]
cont = []
curr = 0
for _ in range(d):
	day = input()
	if '0' in day:
		curr += 1
	else:
		cont += [curr]
		curr = 0
if curr != 0:
	cont += [curr]
print(max(cont))


(n, d) = map(int, input().split())
arr = []
for i in range(d):
	s = str(input())
	arr.append(s)
ansarr = []
for i in range(d):
	flag = 0
	if arr[i].count('0') != 0:
		flag = 1
	if flag == 1:
		ansarr.append(1)
	else:
		ansarr.append(0)
count = 0
ans = 0
for i in range(d):
	if ansarr[i] == 0:
		ans = max(ans, count)
		count = 0
	else:
		count += 1
ans = max(ans, count)
print(ans)


(x, y) = [int(i) for i in input().split()]
c = 0
maxx = 0
for i in range(y):
	a = input()
	b = 1
	for i in a:
		if i == '0':
			b = 0
	if b == 0:
		c += 1
		if maxx < c:
			maxx = c
	else:
		if maxx < c:
			maxx = c
		c = 0
print(maxx)


(n, d) = input().split()
n = int(n)
d = int(d)

def chec(_k):
	for i in range(n):
		if _k[i] != '1':
			return 0
	return 1
ans = tem = 0
for i in range(d):
	k = input()
	if chec(k) == 1:
		ans = max(ans, tem)
		tem = 0
	else:
		tem += 1
print(max(ans, tem))


(n, d) = map(int, input().split())
(a, b) = (0, [])
for x in range(d):
	s = input()
	if '0' in s:
		a += 1
		b.append(a)
	else:
		a = 0
		b.append(a)
print(max(b))


(a, b) = map(int, input().split())
(ans, res) = (0, 0)
for i in range(b):
	res = res + 1 if '0' in input() else 0
	ans = max(ans, res)
print(ans)


(n, d) = input().split()
current_max = 0
current_loop = 0
for i in range(int(d)):
	day = input()
	if '0' in day:
		current_loop = current_loop + 1
		if current_loop > current_max:
			current_max = current_loop
	else:
		current_loop = 0
print(current_max)


(n, d) = map(int, input().split())
p = None
ans = 0
s = 0
for i in range(d):
	o = list(input())
	if o.count('1') < n:
		if p == i - 1:
			s += 1
		else:
			s = 1
		p = i
	ans = max(s, ans)
print(ans)


(no_of_opponents, no_of_days) = map(int, input().split())

def is_win(oppo):
	return '0' in oppo
(win, wins) = (0, [])
for i in range(no_of_days):
	oppo = input()
	if is_win(oppo):
		win += 1
	else:
		wins.append(win)
		win = 0
	wins.append(win)
print(max(wins))


(N, D) = map(int, input().split())
now = 0
ans = -1
for d in range(D):
	inp = input()
	if inp == '1' * N:
		ans = max(ans, now)
		now = 0
	else:
		now += 1
ans = max(ans, now)
print(ans)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
(n, d) = get_list()
schedule = [get_string() for _ in range(d)]
m = count = 0
for i in range(d):
	if schedule[i].count('0') > 0:
		count += 1
	else:
		m = max(m, count)
		count = 0
m = max(m, count)
print(m)


(n, d) = map(int, input().split())
(last, res) = (-1, 0)
for i in range(d):
	if '0' not in input():
		res = max(res, i - last - 1)
		last = i
res = max(res, d - last - 1)
print(res)


a = input().split()
(n, d) = (int(a[0]), int(a[1]))
m = []
count = 0
countmax = 0
for i in range(d):
	a = 1
	num = input()
	m.append(num.count('0'))
for i in range(d):
	if m[i] != 0:
		count += 1
	else:
		if countmax < count:
			countmax = count
		count = 0
if countmax < count:
	countmax = count
print(countmax)


(n, m) = map(int, input().split())
max = 0
z = 0
for i in range(m):
	x = list(input())
	x = list(set(x))
	if len(x) == 1:
		if x[0] == '0':
			z = z + 1
		else:
			if max < z:
				max = z
			z = 0
	else:
		z = z + 1
if z > max:
	print(z)
else:
	print(max)


def solve(n, d, a):
	s = 0
	t = False
	ms = 0
	for i in a:
		if i.count('1') != n:
			t = True
			s += 1
			ms = max(s, ms)
		else:
			s = 0
			t = False
	return ms

def main():
	(n, d) = list(map(int, input().split()))
	a = []
	for _ in range(d):
		x = input()
		a.append(x)
	print(solve(n, d, a))
main()


(n, d) = map(int, input().split())
S = [str(input()) for _ in range(d)]
T = [1 for _ in range(d)]
for i in range(d):
	for j in range(n):
		T[i] *= int(S[i][j])
T = [1 - T[i] for i in range(d)]
for i in range(1, d):
	if T[i]:
		T[i] += T[i - 1]
print(max(T))


(n, d) = map(int, input().split())
ans = temp = 0
for _ in range(d):
	for i in input():
		if i == '0':
			temp += 1
			ans = max(temp, ans)
			break
	else:
		temp = 0
print(ans)


(n, k) = map(int, input().split())
arr3 = []
for _ in range(k):
	arr3.append(input())
count = 0
ans = 0
for i in arr3:
	if '0' in i:
		count += 1
	else:
		count = 0
	ans = max(ans, count)
print(ans)


(n, m) = map(int, input().split())
t = ''
for j in range(m):
	s = input()
	k = 1
	for i in range(n):
		k = k & int(s[i])
	t += str(k)
for i in range(m, 0, -1):
	l = t.count('0' * i)
	if l > 0:
		print(i)
		break
else:
	print(0)


(n, d) = map(int, input().split())
max = 0
s = 0
for i in range(d):
	dd = str(input())
	if dd.count('0'):
		s += 1
	else:
		s = 0
	if s > max:
		max = s
print(max)


(n, d) = map(int, input().split())
ans = 0
cur = 0
for i in range(d):
	x = input()
	if x.count('0') == 0:
		cur = 0
	else:
		cur += 1
	ans = max(ans, cur)
print(ans)


import sys
input = sys.stdin.readline

def io():
	(r, n) = map(int, input().split())
	s = []
	for _ in range(n):
		tmp = input()
		tmp = tmp.replace('\n', '')
		s.append(tmp)
	return (r, n, s)

def solve():
	(r, n, s) = io()
	bad_day = '1' * r
	longest = 0
	tmp = 0
	for i in s:
		if i != bad_day:
			tmp += 1
		else:
			tmp = 0
		longest = max(longest, tmp)
	print(longest)
solve()


(n_opps, n_days) = input().strip().split()
n_days = int(n_days)
n_opps = int(n_opps)
max_cons_wins = 0
curr_cons_wins = 0
for _ in range(n_days):
	n_dayopps = sum((c == '1' for c in input()))
	if n_dayopps != n_opps:
		curr_cons_wins += 1
	else:
		curr_cons_wins = 0
	max_cons_wins = max(max_cons_wins, curr_cons_wins)
print(max_cons_wins)


(n, d) = map(int, input().split())
ans = 0
sav = 0
for i in range(d):
	s = input()
	if s.count('0') == 0:
		ans = max(ans, sav)
		sav = 0
	else:
		sav += 1
ans = max(ans, sav)
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, m) = LI()
	ans = 0
	a = 0
	for i in range(m):
		s = list(S())
		if len(set(s)) == 1 and s[0] == '1':
			ans = max(ans, a)
			a = 0
		else:
			a += 1
	ans = max(ans, a)
	a = 0
	return ans
print(main())


(m, d) = map(int, input().split())
z = 0
count = 0
for i in range(d):
	s = input()
	if '1' * m == s:
		count = 0
	else:
		count += 1
	z = max(z, count)
print(z)


(n, d) = list(map(int, input().split()))
opp = []
for i in range(d):
	opp.append(list(input()))
a = 0
ma = -1
p = 1
for i in range(d):
	if opp[i].count('0') != 0:
		if p:
			a += 1
		else:
			a = 1
			p = 1
	else:
		if a > ma:
			ma = a
		p = 0
		a = 0
if a > ma:
	ma = a
print(ma)


(n, d) = map(int, input().split())
a = [list(map(int, list(input()))) for _ in range(d)]
(mx, c) = (0, 0)
for i in range(d):
	c = c + 1 if sum(a[i]) < n else 0
	mx = max(mx, c)
print(mx)


(N, D) = map(int, input().split())
FLAG = 0
count = 0
max = 0
for i in range(D):
	X = list(input())
	if X.count('1') != N:
		count += 1
		if count > max:
			max = count
	else:
		FLAG = 0
		count = 0
print(max)


(n, d) = map(int, input().split())
current_max = 0
answer = 0
for i in range(d):
	s = list(str(input()))
	if s.count('1') != n:
		current_max += 1
	else:
		answer = max(current_max, answer)
		current_max = 0
answer = max(current_max, answer)
print(answer)


abc = input()
abc = abc.split()
(no1, no2) = (int(abc[0]), int(abc[1]))
count = 0
max = 0
for _ in range(0, no2):
	xyz = list(input())
	if xyz.count('1') is not no1:
		count += 1
	else:
		if count > max:
			max = count
		count = 0
if count > max:
	max = count
print(max)


(n, d) = input().split()
n = int(n)
d = int(d)
max = 0
temp = 0
for i in range(d):
	st = input()
	if '0' in st:
		temp += 1
	else:
		if temp > max:
			max = temp
		temp = 0
if temp > max:
	print(temp)
else:
	print(max)


(n, d) = map(int, input().split())
l = 0
r = 0
for i in range(d):
	s = input()
	if s.count('0') > 0:
		l += 1
	else:
		l = 0
	r = max(r, l)
print(r)


a = input().split()
a[0] = int(a[0])
a[1] = int(a[1])
l = list()
c = 0
for i in range(0, a[1]):
	s = input()
	if '0' in s:
		c = c + 1
	else:
		l.append(c)
		c = 0
l.append(c)
print(max(l))


(a, b) = map(int, input().split())
count = 0
z = 0
for _ in range(b):
	x = input().count('1')
	if x < a:
		count += 1
		if count >= z:
			z = count
	elif x == a:
		count = 0
print(z)


(n, d) = input().split()
n = int(n)
d = int(d)
max_d = 0
cur_d = 0
for x in range(d):
	i = input()
	if '0' in i:
		cur_d += 1
	else:
		max_d = max(max_d, cur_d)
		cur_d = 0
max_d = max(max_d, cur_d)
print(max_d)


import sys
(n, d) = map(int, input().split())
win = mwin = 0
for i in range(d):
	opponents = input()
	if '0' in opponents:
		win += 1
		mwin = max(win, mwin)
	else:
		win = 0
print(mwin)


def read_lines(num_days):
	grid = []
	for day in range(num_days):
		grid.append(input())
	return grid

def main():
	user_input = input().split()
	num_opponents = int(user_input[0])
	num_days = int(user_input[1])
	grid = read_lines(num_days)
	max_days = 0
	temp_days = 0
	losing_string = ''
	for opponent in range(num_opponents):
		losing_string += '1'
	for day in range(num_days):
		if grid[day] != losing_string:
			temp_days += 1
			if temp_days > max_days:
				max_days = temp_days
		else:
			temp_days = 0
	print(max_days)
main()


(n, d) = map(int, input().split())
days = [0] * d
for i in range(d):
	days[i] = input()
k = 0
ans = 0
for i in range(d):
	if '0' in days[i]:
		k += 1
	else:
		if k > ans:
			ans = k
		k = 0
if k > ans:
	ans = k
print(ans)


_input = input().split()
input_list = []
N = int(_input[1])
D = _input[0]
for counter in range(1, N + 1):
	input_list.append(input())
counter_of_winning = 0
highest = 0
continue_counting = True
for x in input_list:
	if x.rfind('0') > -1:
		counter_of_winning = counter_of_winning + 1
		if counter_of_winning > highest:
			highest = counter_of_winning
	else:
		counter_of_winning = 0
print(highest)


(n, d) = list(map(int, input().split()))
a = []
for i in range(d):
	a.append(input())
ans = 0
m = 0
for i in range(d):
	for j in range(n):
		if a[i][j] == '0':
			m += 1
			if m > ans:
				ans = m
			break
	else:
		m = 0
if m > ans:
	ans = m
print(ans)


(n, d) = map(int, input().split())
at = []
for i in range(d):
	x = input()
	at.append(x.count('0'))
i = 0
res = []
while i < d:
	j = 0
	if at[i] != 0:
		while i < d and at[i] != 0:
			j += 1
			i += 1
	else:
		i = i + 1
	res.append(j)
print(max(res))


(n, d) = map(int, input().split())
a = 0
r = 0
for _ in range(d):
	if set('1') != set(input()):
		r += 1
	else:
		r = 0
	a = max(a, r)
print(a)


def main():
	(n, d) = map(int, input().split())
	cnt = 0
	ans = 0
	for _ in range(d):
		op = input()
		if '0' not in op and len(op) == n:
			cnt = 0
		else:
			cnt += 1
		ans = max(ans, cnt)
	print(ans)
main()


char2 = input()
list2 = char2.split()
a = int(list2[0])
b = int(list2[1])
c = 0
mc = 0
list1 = []
for i in range(0, b):
	char = list(input())
	if char.count('0') is 0:
		if c > mc:
			mc = c
		c = 0
	else:
		c += 1
if c > mc:
	mc = c
print(mc)


(n, d) = [int(x) for x in input().split()]
k = 0
maxi = 0
l = []
for i in range(d):
	s = input()
	if '0' in s:
		k += 1
		l.append(k)
	else:
		k = 0
for i in l:
	if i > maxi:
		maxi = i
print(maxi)


(n, d) = map(int, input().split())
(x, y) = ([], [])
s = '1' * n
for _ in range(d):
	x.append(input())
if s not in x:
	print(len(x))
	exit(0)
while s in x:
	i = x.index(s)
	y.append(i)
	del x[0:i + 1]
print(max(max(y), len(x)))


(n, k) = map(int, input().split())
s = ''
(m, z) = (0, 0)
for i in range(k):
	s = input()
	if s.count('0') > 0:
		m += 1
	else:
		if m > z:
			z = m
		m = 0
if m > z:
	z = m
print(z)


s = input()
a = s.find(' ')
n = int(s[0:a])
d = int(s[a:len(s)])
maxi = 0
ma = 0
for x in range(0, d):
	s = input()
	if '0' in s:
		maxi += 1
		if maxi > ma:
			ma = maxi
	else:
		maxi = 0
print(ma)


(n, d) = map(int, input().split())
m = 0
M = 0
for i in range(d):
	s = input()
	if '0' not in s:
		M = max(M, m)
		m = 0
	else:
		m += 1
		M = max(M, m)
print(M)


(n, m) = map(int, input().split())
streak = 0
win = 0
for i in range(m):
	b = input()
	a = []
	for j in range(n):
		a.append(int(b[j]))
	if 0 in a:
		win += 1
	else:
		if win > streak:
			streak = win
		win = 0
if win > streak:
	streak = win
print(streak)


(n, d) = map(int, input().split())
k = 0
ma = 0
for i in range(d):
	s = sum(map(int, list(input().rstrip())))
	if s < n:
		k += 1
	else:
		k = 0
	ma = max(ma, k)
print(ma)


(op, day) = map(int, input().split())
days = 0
d = []
for j in range(day):
	p = input()
	present = 0
	for i in p:
		if i == '1':
			present += 1
	if j == day - 1 and present < op:
		days += 1
		d.append(days)
	elif present < op:
		days += 1
	else:
		d.append(days)
		days = 0
print(max(d))


(n, d) = map(int, input().split())
res = [0]
for i in range(d):
	if input().count('0'):
		res += [res[i] + 1]
	else:
		res += [0]
res.sort(reverse=True)
print(res[0])


(o, d) = map(int, input().split())
x = [0 for i in range(d)]
for i in range(d):
	show = input()
	if '0' in show:
		x[i] = 1
streak = 0
m = 0
for i in range(d):
	if x[i] == 1:
		streak += 1
		m = max(m, streak)
	else:
		streak = 0
print(m)


(n, d) = map(int, input().split())
max = 0
t = []
for i in range(d):
	t.append(input().strip())
t.append('1' * n)
for i in range(d + 1):
	q = 0
	for j in range(i, d + 1):
		if t[j] != '1' * n:
			q += 1
		else:
			if max < q:
				max = q
			break
print(max)


(n, d) = map(int, input().split())
r = []
for i in range(d):
	s = input()
	marker = False
	for j in range(n):
		if s[j] == '0':
			marker = True
	r.append(marker)
cnt = 0
maxx = 0
for i in range(d):
	if r[i] == True:
		cnt += 1
	else:
		if cnt > maxx:
			maxx = cnt
		cnt = 0
print(max(cnt, maxx))


(n, d) = [int(i) for i in input().split()]
k = kmax = 0
for i in range(d):
	a = input()
	if a.count('0'):
		k += 1
	else:
		k = 0
	if kmax < k:
		kmax = k
if kmax == 0:
	kmax = k
print(kmax)


(k, n) = [int(j) for j in input().split()]
(count, res) = (0, 0)
for j in range(n):
	s = str(input())
	if s.count('1') == k:
		count = 0
	else:
		count += 1
		res = max(count, res)
print(res)


(n, d) = map(int, input().split())
a = []
(m, k) = (0, 0)
for i in range(d):
	s = input()
	if '0' in s:
		a.append(1)
	else:
		a.append(0)
for i in range(len(a)):
	if a[i] == 0:
		m = 0
	else:
		m += 1
		k = max(k, m)
print(k)


(n, d) = map(int, input().split())
ll = []
for i in range(d):
	l = input().strip()
	if l.find('0') != -1:
		ll.append(i + 1)
if len(ll) > 0:
	k = 1
	otvet = [1]
	for i in range(1, len(ll)):
		if ll[i - 1] + 1 == ll[i]:
			k += 1
		else:
			if k != 1:
				otvet.append(k)
			k = 1
	otvet.append(k)
	print(max(otvet))
else:
	print(0)


def digitsum(x):
	total = 0
	for letter in x:
		total += ord(letter) - 48
	return total
(n, d) = map(int, input().split())
max_n = 0
cur = 0
for i in range(d):
	s = input()
	if digitsum(s) != n:
		cur += 1
	else:
		if cur > max_n:
			max_n = cur
		cur = 0
print(max(cur, max_n))


[n_opponents, n_days] = [int(_) for _ in input().split()]
results = [0] * (n_days + 1)
for i in range(1, n_days + 1):
	results[i] = results[i - 1] + 1 if '0' in input() else 0
print(max(results))


(n, d) = map(int, input().split())
longestStreak = 0
currentStreak = 0
while d > 0:
	inputLine = list(str(input()))
	if inputLine.count('0') > 0:
		currentStreak = currentStreak + 1
	else:
		currentStreak = 0
	longestStreak = max(longestStreak, currentStreak)
	d = d - 1
print(longestStreak)


def main():
	(n, d) = map(int, input().split())
	(res, t) = ([], 0)
	for _ in range(d):
		if '0' in input():
			t += 1
		else:
			t = 0
		res.append(t)
	print(max(res))
main()


(n, d) = map(int, input().split())
MAX = 0
val = 0
for i in range(d):
	string = input()
	if string.count('0') == 0:
		MAX = max(MAX, val)
		val = 0
	else:
		val += 1
MAX = max(MAX, val)
print(MAX)


(n, d) = [int(i) for i in input().split()]
t = 0
m = 0
z = ''
for i in range(n):
	z += '1'
for i in range(d):
	s = input()
	if s != z:
		t += 1
	else:
		t = 0
	if t > m:
		m = t
print(m)


(n, d) = [int(x) for x in input().split()]
c = 0
ans = 0
for i in range(d):
	s = str(input())
	if '0' in s:
		c += 1
	else:
		c = 0
	ans = max(ans, c)
print(ans)


(n, d) = map(int, input().split())
m = [0] * d
pattern = int('1' * n)
for i in range(d):
	s = int(input())
	if s == pattern:
		m[i] = 1
k = 0
max_k = 0
for i in m:
	if not i:
		k += 1
	else:
		max_k = max(max_k, k)
		k = 0
max_k = max(max_k, k)
print(max_k)


(n, k) = map(int, input().split())
(c, l1) = (0, [])
for i in range(k):
	l = list(input())
	if '0' in l:
		c += 1
	else:
		l1.append(c)
		c = 0
	if i == k - 1:
		l1.append(c)
print(max(l1))


import sys
(n, d) = [int(x) for x in input().split()]
temp = '1' * n
init = 0
maxi = 0
for i in range(0, d):
	ar = input()
	if ar != temp:
		init = init + 1
		if init > maxi:
			maxi = init
	elif ar == temp:
		init = 0
print(maxi, end='')


(n, d) = map(int, input().split())
ones = ''.join(['1'] * n)
ans = 0
prev = -1
for i in range(d):
	s = input()
	if s == ones:
		ans = max(ans, i - prev - 1)
		prev = i
ans = max(ans, d - prev - 1)
print(ans)


s = input()
(m, n) = s.split()
best = win = 0
for i in range(int(n)):
	s = input()
	if '0' in s:
		win += 1
	else:
		win = 0
	best = max(win, best)
print(best)


(n, d) = map(int, input().split())
mx = 0
s = '1' * n
k = 0
for i in range(d):
	inp = input()
	if inp == s:
		k = 0
	else:
		k += 1
	mx = max(mx, k)
print(mx)


wins = []
w_d = input().split()
n = int(w_d[0])
d = int(w_d[1])
current_wins = 0
for line in range(d):
	s = input()
	if '0' in s:
		wins.append('w')
	else:
		wins.append('l')
print(len(max(''.join(wins).split('l'), key=len)))


def fight(ar):
	ans = 0
	fin = 0
	for i in ar:
		if i.count('1') == len(i):
			fin = max(fin, ans)
			ans = 0
		else:
			ans += 1
	return max(fin, ans)
(n, d) = list(map(int, input().rstrip().split()))
arr = []
for i in range(d):
	s = input()
	arr.append(s)
print(fight(arr))


(n, d) = map(int, input().split())
m = []
a = 0
for i in range(d):
	l = input()[:n]
	if '0' in l:
		a = a + 1
	else:
		m.append(a)
		a = 0
	if i == d - 1:
		m.append(a)
print(max(m))


string = input().split(' ')
n = int(string[0])
d = int(string[1])
wins = ''
for i in range(d):
	string = input()
	if '0' in string:
		wins += '1'
	else:
		wins += '0'
longest = 0
current = 0
for i in range(d):
	if wins[i] == '1':
		current += 1
	else:
		current = 0
	if current > longest:
		longest = current
print(longest)


(n, d) = [int(x) for x in input().split()]
L = [0] * (d + 1)
for i in range(d):
	X = input()
	if '0' in X:
		L[i] = 1 + L[i - 1]
	else:
		L[i] = 0
print(max(L))


days = int(input().split()[1])
win_max = 0
win_current = 0
for _ in range(days):
	if '0' in input():
		win_current += 1
		if win_max < win_current:
			win_max = win_current
	else:
		win_current = 0
print(win_max)


import time
(n, d) = (int(i) for i in input().split())
t = [0 for i in range(d)]
for i in range(d):
	t[i] = sum([int(j) for j in list(input())])
start = time.time()
ans = 0
now = 0
for i in range(d):
	if t[i] == n:
		if now > ans:
			ans = now
		now = 0
	else:
		now = now + 1
if now > ans:
	ans = now
print(ans)
finish = time.time()


(a, b) = list(map(int, input().split()))
cnt = 0
mx = 0
for i in range(b):
	l = list(map(int, input()))
	if l.count(1) < len(l):
		cnt = cnt + 1
	else:
		cnt = 0
	mx = max(mx, cnt)
print(mx)


import sys
(n, d) = map(int, sys.stdin.readline().split())
ans = 0
crt = 0
for _ in range(d):
	a = input().strip()
	if a == '1' * n:
		ans = max(ans, crt)
		crt = 0
	else:
		crt += 1
ans = max(ans, crt)
print(ans)


(n, d) = map(int, input().split())
a = []
w = 0
k = True
for i in range(d):
	s = input()
	if s.count('1') < len(s):
		w += 1
	else:
		a.append(w)
		w = 0
		k = False
	if i + 1 == d:
		a.append(w)
if k == True:
	print(d)
else:
	print(max(a))


(n, d) = map(int, input().split())
max_ = 0
win = 0
for _ in range(d):
	s = input()
	if s.count('0') > 0:
		win += 1
	else:
		win = 0
	max_ = max(max_, win)
print(max_)


(n, m) = map(int, input().split())
count = 0
l1 = []
for j in range(m):
	s1 = input()
	if s1.count('1') == n:
		l1.append(count)
		count = 0
	elif j == m - 1:
		count += 1
		l1.append(count)
	else:
		count += 1
print(max(l1))


(n, d) = input().split()
n = int(n)
d = int(d)
count = 0
flag = 1
res_count = 0
for i in range(d):
	s = input()[:n]
	for x in s:
		if x == '0' and flag == 1:
			count += 1
			res_count = max(res_count, count)
			break
	else:
		count = 0
print(res_count)


s = input().split()
(n, d) = (int(s[0]), int(s[1]))
D = [0] * d
for i in range(0, d):
	enemies = input()
	if '0' in enemies:
		D[i] = 1
best = 0
current = 0
for i in D:
	if i == 1:
		current += 1
	else:
		best = max(best, current)
		current = 0
print(max(best, current))


(n, d) = map(int, input().split())
win = 0
winlist = []
for i in range(d):
	enemies = list(map(int, input()))
	if 0 in enemies:
		win += 1
	else:
		winlist.append(win)
		win = 0
if win > 0:
	winlist.append(win)
if len(winlist) > 0:
	print(max(winlist))
else:
	print(win)


def main():
	first = input()
	(n, d) = first.split(' ')
	d = int(d)
	count = []
	maxi = 0
	for i in range(d):
		n = input()
		if '0' in n:
			maxi = maxi + 1
		else:
			count.append(maxi)
			maxi = 0
	count.append(maxi)
	print(max(count))
main()


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	(n, d) = read_ints()
	A = ['0' in input() for _ in range(d)]
	MAX = 0
	count = 0
	for (i, x) in enumerate(A):
		if x is False:
			count = 0
		else:
			count += 1
			MAX = max(MAX, count)
	print(MAX)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


(o, d) = list(map(int, input().split()))
b = []
for i in range(d):
	s = input()
	b.append(s)
count = 0
c = []
for i in b:
	if '0' in i:
		count += 1
		c.append(count)
	else:
		c.append(count)
		count = 0
print(max(c))


(n, d) = input().split()
n = int(n)
d = int(d)
opps = []
beat = '1' * n
count = 0
for i in range(0, d):
	s = input()
	opps.append(s)
score = []
for x in opps:
	if x != beat:
		count += 1
	elif x == beat:
		score.append(count)
		count = 0
score.append(count)
print(max(score))


(n, k) = map(int, input().split())
l = []
count = 0
hight = 0
for i in range(k):
	l.append(input())
for i in range(len(l)):
	if l[i].find('0') != -1:
		count += 1
	else:
		hight = max(count, hight)
		count = 0
hight = max(count, hight)
print(hight)


(a, n) = map(int, input().split())
(counter, sum) = (0, 0)
for i in range(n):
	a = input()
	if '0' in a:
		counter += 1
	else:
		counter = 0
	if counter > sum:
		sum = counter
print(sum)


(n, m) = list(map(int, input().strip().split()))
l = []
t = 0
for i in range(m):
	a = input()
	if a.count('1') == n:
		l += [t]
		t = 0
	else:
		t += 1
else:
	l += [t]
print(max(l))


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(r, c) = get_int()
ans = 0
tmp = 0
for i in range(c):
	if '0' not in input():
		ans = max(ans, tmp)
		tmp = 0
	else:
		tmp += 1
print(max(ans, tmp))


(n, n2) = map(int, input().split())
ar = []
counter = 0
for r in range(n2):
	str1 = input()
	if '1' * n not in str1:
		counter = counter + 1
	else:
		ar.append(counter)
		counter = 0
	if r == n2 - 1 and '1' * n not in str1:
		ar.append(counter)
s = 0
for v in ar:
	if s < v:
		s = v
print(s)


(n, d) = map(int, input().split(' '))
l = []
tl = ''
fl = ''
for i in range(d):
	l.append(input())
for i in range(n):
	tl += '1'
maxCount = 0
count = 0
for i in l:
	if i != tl:
		count += 1
	else:
		if count > maxCount:
			maxCount = count
		count = 0
if count > maxCount:
	maxCount = count
print(maxCount)


(n, d) = map(int, input().split())
l = z = 0
for i in range(d):
	k = input()
	s = 0
	for i in k:
		if i == '1':
			s += 1
	if s < n:
		l += 1
	elif s == n:
		l = 0
	z = max(z, l)
print(z)


inp = list(map(int, input().split()))
from collections import Counter
n = inp[0]
d = inp[1]
l = []
ans = 0
sumi = 0
for i in range(d):
	inp = input()
	c = Counter(inp)
	l.append(c['1'])
for i in range(d):
	if l[i] < n:
		sumi += 1
		if sumi > ans:
			ans = sumi
	else:
		sumi = 0
print(ans)


(n, m) = map(int, input().split())
k = 0
ma = 0
for i in range(m):
	S = input()
	c = 0
	for j in range(len(S)):
		if S[j] == '0':
			k = k + 1
			c = 1
			break
	if c == 0:
		k = 0
	if k >= ma:
		ma = k
if k >= ma:
	ma = k
print(ma)


from decimal import *
from sys import *
from math import *
(n, d) = map(int, input().split())
l = [0]
for i in range(1, d + 1):
	s = input().strip()
	if s == '1' * n:
		l.append(i)
l.append(d + 1)
ans = 0
for i in range(1, len(l)):
	ans = max(ans, l[i] - l[i - 1] - 1)
print(ans)


(n, d) = map(int, input().split())
arr = []
for _ in range(d):
	x = input()
	arr.append(x)
r = 0
res = [0]
for i in range(len(arr)):
	if arr[i].count('0') > 0:
		r += 1
	else:
		res.append(r)
		r = 0
res.append(r)
print(max(res))


(n, d) = [int(x) for x in input().split()]
strings = []
for x in range(d):
	strings.append(input())
maxStreak = 0
cur = 0
for s in strings:
	if '0' in s:
		cur = cur + 1
	else:
		if cur > maxStreak:
			maxStreak = cur
		cur = 0
print(max(cur, maxStreak))


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
from math import ceil, floor, log, sqrt, factorial, pow, pi

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p1
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph():
	d = {}
	(v, e) = mi()
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(l, n):
	d = {}
	for i in range(1, n + 1):
		if i not in d.keys():
			d[i] = l[i]
		else:
			d[i].append(l[i])
	return d
(n, d) = mi()
count = 0
max = 0
for i in range(d):
	s = input()
	if '0' in s:
		count += 1
	else:
		count = 0
	if count > max:
		max = count
print(max)


(n, d) = map(int, input().split(' '))
count = 0
b = []
for i in range(d):
	a = list(map(int, input()))
	sum1 = 0
	for j in range(n):
		sum1 = sum1 + a[j]
	if sum1 < n:
		count = count + 1
		b.append(count)
	elif sum1 == n:
		count = 0
		b.append(count)
print(max(b))


a = input()
s = ''
A = []
for i in a:
	if i == ' ':
		A.append(int(s))
		s = ''
	else:
		s += i
A.append(int(s))
s = ''
b = []
for i in range(A[1]):
	b.append(input())
cnt = 0
bg = 0
for i in b:
	if i != A[0] * '1':
		cnt += 1
	else:
		if bg < cnt:
			bg = cnt
		cnt = 0
if bg < cnt:
	bg = cnt
print(bg)


(n, d) = map(int, input().split())
win = []
for a in range(d):
	dan = input()
	if dan.count('0') > 0:
		win.append(1)
	else:
		win.append(0)
red = 0
redovi = []
for b in range(d):
	if win[b] == 1:
		red += 1
		if b == d - 1:
			redovi.append(red)
	else:
		redovi.append(red)
		red = 0
print(max(redovi))


(s, n) = list(map(int, input().split(' ')))
c = 0
l1 = []
for i in range(n):
	s = input()
	l = [int(x) for x in str(s)]
	if 0 in l:
		c = c + 1
	else:
		l1.append(c)
		c = 0
l1.append(c)
l1.sort()
print(l1[len(l1) - 1])


(o, n) = map(int, input().split())
l = 0
t = 0
for i in range(n):
	a = str(input())
	f = 0
	for j in range(o):
		if a[j] == '0':
			t = t + 1
			f = 1
			break
	if t > l:
		l = t
	if f == 0:
		t = 0
print(l)


(n, d) = map(int, input().split(' '))
l = 0
m = []
for i in range(d):
	s = str(input())
	if s.count('1') != n:
		l += 1
	else:
		m.append(l)
		l = 0
m.append(l)
print(max(m))


(n, d) = input().split()
(n, d) = (int(n), int(d))
maximum = 0
current = 0
for each_d in range(d):
	s = input()
	if s.count('1') != n:
		current = current + 1
		if current > maximum:
			maximum = current
	else:
		current = 0
print(maximum)


(opponents_count, days_count) = map(int, input().split())
res = ''.join(('1' if '0' in input() else '0' for i in range(days_count))).split('0')
print(max((len(seq) for seq in res)))


I = input().split()
N = int(I[0])
D = int(I[1])
count = 0
maxdays = 0
for i in range(0, D):
	win = False
	opponents = input()
	for j in range(0, N):
		if opponents[j] == '0':
			win = True
	if win == True:
		count += 1
	else:
		count = 0
	if maxdays < count:
		maxdays = count
print(maxdays)


(a, b) = list(map(int, input().split()))
s = []
f = 0
for i in range(b):
	t = list(input())
	if '0' in t:
		f += 1
	else:
		s.append(f)
		f = 0
	s.append(f)
S = set(s)
print(max(S))


n = list(map(int, input().split()))
kill_Strike = 0
KD = []
for _ in range(n[1]):
	if '0' in input():
		kill_Strike += 1
	else:
		KD.append(kill_Strike)
		kill_Strike = 0
KD.append(kill_Strike)
print(max(KD))


(a, b) = map(int, input().strip().split())
c = 0
s = []
for i in range(b):
	q = input()
	q = list(q)
	if q.count('1') != a:
		c += 1
		s.append(c)
	else:
		c = 0
		s.append(c)
print(max(s))


(n, d) = list(map(int, input().split()))
c = 0
maxso = 0
for i in range(d):
	s = input()
	if '0' in s:
		c += 1
	else:
		maxso = max(c, maxso)
		c = 0
print(max(maxso, c))


def inp():
	return map(int, input().split())
(n, d) = inp()
(ans, c) = (0, 0)
for i in range(d):
	s = input()
	if s.count('1') < n:
		c += 1
	else:
		c = 0
	ans = max(ans, c)
print(ans)


(n, d) = map(int, input().split())
ret = 0
consecutive = 0
for i in range(d):
	s = input()
	if s.count('1') == n:
		ret = max(ret, consecutive)
		consecutive = 0
	else:
		consecutive += 1
ret = max(ret, consecutive)
print(ret)


import sys
(n, d) = map(int, sys.stdin.readline().split())
arr = []
for i in range(1, d + 1):
	ch = str(input())
	if set(ch) != {'1'}:
		arr.append(1)
	else:
		arr.append(0)
arr1 = []
qq = 0
for i in range(len(arr)):
	if arr[i] == 1:
		qq = qq + 1
		arr1.append(qq)
	else:
		qq = 0
		arr1.append(0)
print(max(arr1))


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
(n, d) = MAP()
mx = 0
cnt = 0
for i in range(d):
	s = STR()
	if len(set(s)) == 1:
		if s[0] == '1':
			cnt = 0
			mx = max(mx, cnt)
		else:
			cnt += 1
			mx = max(mx, cnt)
	else:
		cnt += 1
		mx = max(mx, cnt)
print(mx)


(a, b) = map(int, input().strip().split()[:2])
c = count = 0
for x in range(b):
	s = list(map(int, input().strip()[:a]))
	if all(s) == True:
		count = 0
	else:
		count += 1
		if count > c:
			c = count
print(c)