#include <bits/stdc++.h>
using namespace std;
long long n, d, temp, tmp, ans, i, j;
bool flag;
char x;
int main() {
  cin >> n >> d;
  tmp = ans = 0;
  for (i = 1; i <= d; i++) {
    flag = false;
    for (j = 1; j <= n; j++) {
      cin >> x;
      if (x != '1') flag = true;
    }
    if (flag)
      tmp++;
    else
      tmp = 0;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
