#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  string s[d];
  string ans = "";
  for (int i = 0; i < n; i++) {
    ans += '1';
  }
  int count = 0;
  for (int i = 0; i < d; i++) {
    cin >> s[i];
  }
  int max = 0;
  for (int i = 0; i < d; i++) {
    if (s[i] == ans) {
      if (max < count) {
        max = count;
      }
      count = 0;
    } else {
      count++;
    }
  }
  if (max < count) {
    max = count;
    count = 0;
  }
  cout << max << endl;
  return 0;
}
