#include <bits/stdc++.h>
using namespace std;
int n, d;
string s;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> d;
  int ans = 0, res = 0;
  while (d--) {
    cin >> s;
    bool l = false;
    for (int i = 0; i < s.size(); i++)
      if (s[i] == '0') {
        l = true;
        break;
      }
    if (!l) {
      if (ans < res) ans = res;
      res = 0;
    } else
      res++;
  }
  if (res > ans) ans = res;
  cout << ans;
  return 0;
}
