#include <bits/stdc++.h>
using namespace std;
int foe(int n, string a);
int main() {
  int n, d, count = 0, max = 0;
  cin >> n >> d;
  string str;
  register int i;
  for (i = 0; i < d; i++) {
    cin >> str;
    if (foe(n, str))
      count++;
    else {
      if (count > max) max = count;
      count = 0;
    }
  }
  if (count > max) max = count;
  cout << max;
  return 0;
}
int foe(int n, string a) {
  register int i;
  for (i = 0; i < n; i++)
    if (a[i] == '0') return 1;
  return 0;
}
