#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  string allPresent = "";
  for (int i = int(1); i <= int(n); i++) allPresent += "1";
  int con = 0, maxCon = 0;
  for (int i = int(1); i <= int(d); i++) {
    string s;
    cin >> s;
    if (s != allPresent) {
      con++;
      maxCon = max(maxCon, con);
    } else {
      con = 0;
    }
  }
  cout << maxCon;
  return 0;
}
