#include <bits/stdc++.h>
using namespace std;
void Cond(int g) {
  if (g)
    cout << ("YES") << endl;
  else
    cout << ("NO") << endl;
  return;
}
void cond(int g) {
  if (g)
    cout << ("Yes") << endl;
  else
    cout << ("No") << endl;
  return;
}
long long comb(long long i, long long j) {
  long long up = 1;
  for (long long n = i; n > i - j; n--) {
    up *= n;
  }
  long long down = 1;
  for (long long r = j; r >= 1; r--) down *= r;
  return up / (down);
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  gcd(b, a % b);
}
long long Digits(long long k) {
  long long t = 0;
  while (k) {
    t += k % 10;
    k /= 10;
  }
  return t;
}
string su = "0123456789";
string m1 = "abcdefghijklmnopqrstuvwxyz";
string m2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
map<char, long long> m5;
const long long INF = (long long)1e17;
const long long MAX = (long long)1e5 + 5;
const long long NIL = -1;
struct Node {
  long long p, l, r;
};
typedef struct edge2 {
  pair<long long, long long> to;
  long long cost;
} EDGE2;
typedef struct edge1 {
  long long to, cost;
} EDGE;
typedef struct edge {
  long long to, cap, rev;
} EDGE3;
long long ans = 0, ct = 0, ct1 = 0, ct2 = 0, cnt = 0, tmp = 0, g = 0, n = 0,
          m = 0;
long long tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0, sum = 0, pos = 0, k = 0;
long long len = 0, len1 = 0, len2 = 0, len3 = 0, len4 = 0, len5 = 0;
long long mx = -INF, mn = INF, mask = 0, ans1 = 0, ans2 = 0;
long long t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0;
long long t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0;
map<long long, long long> mp, mp1, mp2, mp3, mp4;
set<long long> st, st1, st2, st3, st4, st5;
set<pair<long long, long long>> pst, pst1, pst2;
set<char> cst, cst1, cst2;
const long long MOD = (long long)1e9 + 7;
const long long M = MOD;
vector<long long> fac(1e6), ifac(1e6);
vector<long long> v, v1, v2, v3, v4, v5, v6, v7;
vector<long long> rui(MAX * 5), rui1(MAX * 5), rui2(MAX * 5);
long long powmod(long long a, long long b, long long x) {
  if (!b) return 1;
  if (!(b % 2)) {
    long long t = powmod(a, b / 2, x);
    return t * t % x;
  }
  return ((a)*powmod(a, b - 1, x)) % x;
}
long long cmb(long long a, long long b) {
  if (a < b || a < 0 || b < 0) return 0;
  if (!a && !b) return 1;
  tmp = ifac[a - b] * ifac[b] % MOD;
  return (tmp * fac[a]) % MOD;
}
void ncr() {
  fac[0] = ifac[0] = 1;
  for (long long i = 0; i < 1e6; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M;
    ifac[i + 1] = ifac[i] * (powmod(i + 1, M - 2, M)) % M;
  }
}
long long soinsu(long long k) {
  long long x = k;
  long long num = 0;
  for (int i = 2; (i * i) <= x; i++) {
    while (!(k % i)) {
      k /= i;
      if (i >= 4) return -100;
      if (i == 2) {
        ct++;
      } else if (i == 3)
        cnt++;
    }
  }
  if (k != 1) {
    if (k % 3 == 0) {
      cnt++;
    } else if (k % 2 == 0) {
      ct++;
    } else
      return -100;
  }
  if (k != 1) num++;
  return num;
}
class UF {
 public:
  vector<long long> rank, par, siz;
  UF(long long s) {
    rank.resize(s + 4, 0), par.resize(s + 4);
    for (long long i = 1; i < s + 1; i++) par[i] = i;
    siz.resize(s, 1);
    return;
  }
  void unite(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (rank[x] > rank[y]) {
      par[y] = x;
      siz[y] += siz[x];
      siz[x] = siz[y];
      return;
    }
    if (rank[x] == rank[y]) {
      rank[y]++;
    }
    par[x] = y;
    siz[x] += siz[y];
    siz[y] = siz[x];
  }
  long long root(long long x) {
    if (par[x] != x) {
      par[x] = root(par[x]);
    }
    return par[x];
  }
  long long same(long long x, long long y) {
    return (root(x) == root(y)) ? 1 : 0;
  }
  long long vsize(long long x) { return siz[root(x)]; }
};
void maker() {
  srand((unsigned int)time(NULL));
  for (long long i = 0; i < 14; i++) {
    t5 = rand() % 50 + 1;
    if (i) cout << " ";
    cout << t5;
  }
  cout << endl;
}
void make_random_permutation(long long x) {
  srand((unsigned int)time(NULL));
  v.resize(11);
  for (long long i = 1; i < x + 1; i++) v[i] = i;
  long long ct3 = 0;
  st2.clear();
  while (ct3 < x) {
    t5 = rand() % x + 1;
    if (st2.find(t5) == st2.end()) {
      v[t5] = ++ct3;
      st2.insert(t5);
    }
  }
  for (long long i = 1; i < x + 1; i++) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}
void di() {
  m5['a'] = 0;
  m5['b'] = 1;
  m5['c'] = 2;
  m5['d'] = 3;
  m5['e'] = 4;
  m5['f'] = 5;
  m5['g'] = 6;
  m5['h'] = 7;
  m5['i'] = 8;
  m5['j'] = 9;
  m5['k'] = 10;
  m5['l'] = 11;
  m5['m'] = 12;
  m5['n'] = 13;
  m5['o'] = 14;
  m5['p'] = 15;
  m5['q'] = 16;
  m5['r'] = 17;
  m5['s'] = 18;
  m5['t'] = 19;
  m5['u'] = 20;
  m5['v'] = 21;
  m5['w'] = 22;
  m5['x'] = 23;
  m5['y'] = 24;
  m5['z'] = 25;
}
vector<long long> dat((long long)1e6, 0);
void init(long long n3) {
  n = 1;
  while (n < n3) {
    n *= 2;
  }
  dat.resize(n, 0);
  return;
}
long long f14(long long a, long long b, long long k2, long long l,
              long long r) {
  if (r <= a || b <= l) return -INF;
  if (a <= l && r <= b) return dat[k2];
  long long q1 = f14(a, b, (2 * k2) + 1, l, (l + r) / 2);
  long long q2 = f14(a, b, (2 * k2) + 2, (l + r) / 2, r);
  return max(q1, q2);
}
void update(long long k1, long long a) {
  k1 += n - 1;
  dat[k1] = a;
  while (k1 > 0) {
    k1 = (k1 - 1) / 2;
    dat[k1] = max(dat[(2 * k1) + 1], dat[(2 * k1) + 2]);
  }
  return;
}
bool used[(long long)1e8];
vector<vector<EDGE3>> G4(1e6);
void add_edge(long long from, long long to, long long capaci) {
  G4[from].push_back((edge){to, capaci, (long long)G4[to].size()});
  G4[to].push_back((EDGE3){from, 0, (long long)G4[from].size() - 1});
  return;
}
long long fdfs(long long v, long long t, long long f) {
  if (v == t) return f;
  used[v] = 1;
  for (long long i = 0; i < G4[v].size(); i++) {
    EDGE3 &e = G4[v][i];
    if (!used[e.to] && e.cap > 0) {
      long long d = fdfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G4[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
long long maxflow(long long s, long long t) {
  long long flow = 0;
  while (1) {
    memset(used, 0, sizeof(used));
    long long f = fdfs(s, t, INF);
    if (!f) return flow;
    flow += f;
  }
}
vector<vector<EDGE>> G(1e6);
vector<long long> dist(1e6, INF);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  clock_t start = clock();
  cin >> n;
  long long d;
  cin >> d;
  for (long long i = 0; i < d; i++) {
    string s;
    cin >> s;
    t1 = 0;
    for (long long j = 0; j < n; j++) t1 += (s[j] == '1');
    mp[i] = (t1 < n);
  }
  for (long long i = 0; i < d; i++) {
    if (!g && !mp[i]) {
      continue;
    }
    if (!g && mp[i]) {
      mx = max(mx, g);
      g = 1;
      continue;
    }
    if (g && mp[i]) {
      mx = max(mx, g);
      g++;
      continue;
    }
    if (g && !mp[i]) {
      mx = max(mx, g);
      g = 0;
      continue;
    }
  }
  cout << ((mx != -INF) ? (long long)max(g, mx) : 1 ^ 1) << endl;
  clock_t end = clock();
  return 0;
}
