#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int mx = 0, consc = 0;
  for (int i = 0; i < d; ++i) {
    bool all = 1;
    for (int i = 0; i < n; ++i) {
      char c;
      cin >> c;
      if (c == '0') all = 0;
    }
    if (!all)
      consc++;
    else
      consc = 0;
    mx = max(mx, consc);
  }
  cout << mx << endl;
}
