#include <bits/stdc++.h>
using namespace std;
vector<int> divisors[500007 + 1];
void divisors_1_to_n(int n) {
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) divisors[j].push_back(i);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  divisors_1_to_n(500007 + 1);
  int i, n, d, mx = 0, cmx = 0;
  cin >> n >> d;
  string s;
  for (i = 0; i < d; i++) {
    cin >> s;
    int c = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '1') c++;
    }
    if (s.size() != c)
      cmx++;
    else {
      if (mx < cmx) mx = cmx;
      cmx = 0;
    }
  }
  if (mx < cmx) mx = cmx;
  cout << mx << endl;
  ;
}
