#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, i, j, k, kd, mk;
  string a;
  kd = mk = 0;
  cin >> n >> d;
  for (i = 1; i <= d; i++) {
    cin >> a;
    k = 0;
    for (j = 1; j <= n; j++) {
      if (a[j - 1] == '1')
        k++;
      else
        break;
    }
    if (k < n) {
      kd++;
      if (kd > mk) mk = kd;
    } else
      kd = 0;
  }
  if (kd > mk) mk = kd;
  cout << mk;
  return 0;
}
