#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 13;
int main() {
  int n, d;
  cin >> n >> d;
  int a[111], cnt = 0;
  a[cnt++] = 0;
  for (int i = 1; i <= d; i++) {
    char c;
    bool ok = true;
    for (int j = 0; j < n; j++) {
      cin >> c;
      if (c == '0') ok = false;
    }
    if (ok) a[cnt++] = i;
  }
  a[cnt++] = d + 1;
  int ans = 0;
  for (int i = 1; i < cnt; i++) ans = max(ans, a[i] - a[i - 1] - 1);
  cout << ans << endl;
  return 0;
}
