#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 30 * 1000 + 20;
const long long MAXN = 401;
const long long MLOG = 18;
const long long NMAX = 60;
signed main() {
  long long n, m, ans = 0;
  cin >> m >> n;
  string s, s1;
  for (long long i = 0; i < m; i++) {
    s1 += '1';
  }
  long long now = 0;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    if (s == s1)
      now = 0;
    else
      now++, ans = max(ans, now);
  }
  cout << ans;
}
