#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string one;
  for (int i = 0; i < n; i++) {
    one += "1";
  }
  vector<string> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  vector<int> d(m);
  for (int i = 0; i < m; i++) {
    if (a[i] == one) {
      d[i] = 0;
    } else {
      d[i] = 1;
    }
  }
  int ans = 0;
  bool ok = false;
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (d[i] == 1) {
      cnt += 1;
      if (ans < cnt) ans = cnt;
    } else {
      cnt = 0;
    }
  }
  cout << ans << '\n';
  return 0;
}
