#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, d, cur = 0, ans = 0;
  cin >> n >> d;
  for (int i = int(0); i < (int)d; ++i) {
    string s;
    cin >> s;
    bool is = true;
    for (int j = int(0); j < (int)s.size(); ++j) {
      if (s[j] == '0') is = false;
    }
    if (!is)
      cur++;
    else
      cur = 0;
    ans = max(cur, ans);
  }
  cout << ans << endl;
  return 0;
}
