#include <bits/stdc++.h>
using namespace std;
int op, d;
int main() {
  int nc = 0, bst = 0;
  ;
  for (cin >> op >> d; d--;) {
    string s;
    cin >> s;
    int c = 0;
    for (int i = 0; i < s.size(); ++i)
      if (s[i] == '1') ++c;
    if (c == op)
      nc = 0;
    else
      ++nc;
    bst = max(nc, bst);
  }
  cout << bst;
}
