#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int count = 0, mx_dys = INT_MIN;
  int cnt1 = 0;
  for (int i = 0; i < d; i++) {
    string s;
    cin >> s;
    cnt1 = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') cnt1++;
    }
    if (cnt1 == n) {
      if (count > mx_dys) mx_dys = count;
      count = 0;
    } else
      count += 1;
  }
  cout << max(count, mx_dys) << endl;
  return 0;
}
