#include <bits/stdc++.h>
using namespace std;
int n, d, sum, ans;
char s[105];
int main() {
  scanf("%d %d", &n, &d);
  for (int i = 0; i < d; i++) {
    scanf("%s", s);
    bool ok = true;
    for (int j = 0; j < n; j++)
      if (s[j] == '0') ok = false;
    if (ok)
      sum = 0;
    else
      sum++, ans = max(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}
