#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  string tocmp = "";
  for (int i = 1; i <= n; ++i) {
    tocmp.push_back('1');
  }
  int mx = 0;
  int cur = 0;
  for (int i = 1; i <= d; ++i) {
    string a;
    cin >> a;
    if (a == tocmp) {
      cur = 0;
    } else {
      cur++;
      if (cur > mx) {
        mx = cur;
      }
    }
  }
  cout << mx << "\n";
  return 0;
}
