#include <bits/stdc++.h>
using namespace std;
const int inf_int = 2e9;
const long long inf_ll = 2e18;
char s[105];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  scanf("%d%d", &n, &d);
  int num = 0;
  int maxn = 0, j;
  for (int i = 0; i < d; i++) {
    scanf("%s", s);
    for (j = 0; j < n; j++) {
      if (s[j] == '0') {
        num++;
        break;
      }
    }
    if (s[j - 1] == '1' && j == n) {
      maxn = max(maxn, num);
      num = 0;
    }
  }
  maxn = max(maxn, num);
  cout << maxn << endl;
  return 0;
}
