#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  scanf("%d", &n);
  scanf("%d", &d);
  map<int, bool> flag;
  for (int i = 1; i <= d; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '0') flag[i] = true;
    }
  }
  int ans = 0, res = 0, prev = 0;
  for (int i = 1; i <= d; i++) {
    res = max(res, ans);
    if (!flag[i])
      ans = 0;
    else
      ans++;
  }
  res = max(res, ans);
  cout << res;
  printf("\n");
  return 0;
}
