#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  string s;
  int cnt, last = 0;
  int ans = 0;
  for (int i = 0; i < d; i++) {
    cin >> s;
    cnt = 0;
    for (int j = 0; j < n; j++) cnt += (s[j] - '0');
    if (cnt == n) {
      ans = max(ans, i - last);
      last = i + 1;
    }
  }
  ans = max(ans, d - last);
  cout << ans;
  return 0;
}
