#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, i, j, mx = 0, f = 0, tmp, x, c = 0;
  string s;
  scanf("%lld %lld", &n, &d);
  while (d--) {
    cin >> s;
    x = 0;
    for (i = 0; i < s.size(); i++) {
      x += (s[i] - 48);
    }
    if (x == n) {
      if (c > mx) mx = c;
      c = 0;
    } else {
      c++;
    }
  }
  if (c > mx) mx = c;
  printf("%lld\n", mx);
  return 0;
}
