#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}
long long int node, edge, vis[200010], dist[200010], col[200010], in[200010],
    out[200010], timer = 0, mind, mnode, ans;
vector<long long int> gh[200010], ind, anr;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  ;
  vector<long long int> u, v, uu, vv, first, last;
  map<long long int, long long int> mp, mq, mpq;
  vector<pair<long long int, long long int> > vp, vq;
  set<long long int> stt;
  set<long long int>::iterator it;
  long long int x, y, z, c, d, e, f, g, h, i, j, k, l, m, n, o,
      p = 0, q = 0, r, t, ck = 0, sum = 0, mx = 0, mn = LONG_LONG_MAX;
  string s, s1, s2, tt;
  cin >> n >> d;
  while (d--) {
    cin >> s;
    p = count(s.begin(), s.end(), '1');
    if (p == n) {
      mx = max(mx, ck);
      ck = 0;
    } else
      ck++;
  }
  mx = max(mx, ck);
  cout << mx << "\n";
  return 0;
}
