#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int t = 0, ans = 0;
  for (int i = 0; i < m; ++i) {
    string s;
    cin >> s;
    bool ck = true;
    for (int j = 0; j < n; ++j) {
      if (s[j] == '0') {
        ck = false;
        break;
      }
    }
    if (ck == false) ++t;
    if (ck == true) {
      ans = max(t, ans);
      t = 0;
    }
  }
  ans = max(t, ans);
  cout << ans << "\n";
  return 0;
}
