#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  return b == 0 ? abs(a) : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int prime[1000000];
void seive() {
  int n_prime = 1000000;
  fill_n(prime, n_prime, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n_prime; i++) {
    if (prime[i]) {
      for (int j = i * i; j <= n_prime; j += i) {
        prime[j] = 0;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, d, id;
  std::cin >> n >> d;
  char c;
  vector<int> ans;
  for (int i = 0; i < d; i++) {
    id = 0;
    for (int j = 0; j < n; j++) {
      std::cin >> c;
      if (c == '0') {
        id = 1;
      }
    }
    ans.push_back(id);
  }
  id = 0;
  int ma = 0, sum = 0;
  for (auto i : ans) {
    if (i == 1 && id == 0) {
      sum++;
      id = 1;
    } else if (i == 1 && id == 1) {
      sum++;
    } else if (i == 0 && id == 1) {
      ma = max(ma, sum);
      id = 0;
      sum = 0;
    }
  }
  if (id == 1 && ans[(int)ans.size() - 1] == 1) {
    ma = max(ma, sum);
  }
  std::cout << ma << '\n';
  return 0;
}
