#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long temp;
  if (b % 2 == 0) {
    temp = pow1(a, b / 2);
    temp = temp % 1000000007;
    temp = temp * temp;
    temp = temp % 1000000007;
    return temp;
  } else {
    temp = pow1(a, b / 2);
    temp = temp % 1000000007;
    temp = temp * temp;
    temp = temp % 1000000007;
    temp = temp * a;
    temp = temp % 1000000007;
    return temp;
  }
}
int main() {
  long long n, d, i;
  scanf("%lld", &n);
  scanf("%lld", &d);
  long long ans[10002];
  for (i = 0; i < 1002; i++) {
    ans[i] = 0;
  }
  for (i = 0; i < d; i++) {
    string temp;
    cin >> temp;
    long long j;
    for (j = 0; j < n; j++) {
      if (temp[j] == '0') {
        ans[i] = 1;
      }
    }
  }
  long long ans1 = 0;
  long long cnt = 0;
  for (i = 0; i < d; i++) {
    if (ans[i] == 1) {
      cnt++;
    } else {
      cnt = 0;
    }
    if (cnt > ans1) ans1 = cnt;
  }
  printf("%lld\n", ans1);
  return 0;
}
