#include <bits/stdc++.h>
const int inf = (1 << 30) - 10;
using namespace std;
inline int get_int() {
  int r = 0;
  char c;
  while ((c = getchar()) != ' ' && c != '\n') r = r * 10 + c - '0';
  return r;
}
inline void out(int x) {
  if (x > 10) {
    out(x / 10);
  }
  putchar(x % 10 + '0');
  putchar('\n');
}
int main() {
  int m, n, ma, x, mm;
  char c[200];
  scanf("%d%d", &m, &n);
  ma = 0;
  x = 0;
  for (int i = 0; i < n; i++) {
    cin >> c;
    mm = 0;
    for (int i = 0; i < m; i++) {
      mm += c[i] - '0';
    }
    if (mm == m) {
      if (x > ma) ma = x;
      x = 0;
    } else
      x++;
  }
  if (x > ma) ma = x;
  printf("%d\n", ma);
  return 0;
}
