#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  string s;
  int ans = 0, cnt = 0;
  bool bo = false;
  for (int i = 0; i < d; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '0') bo = true;
    }
    if (!bo) {
      if (cnt > ans) ans = cnt;
      cnt = 0;
    } else
      cnt++;
    bo = false;
  }
  cout << max(ans, cnt);
}
