#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int i, j;
  char str[1000];
  int ans = 0;
  int flag = 0;
  int res = 0;
  int max = 0;
  for (i = 0; i < d; i++) {
    for (j = 0; j < n; j++) {
      cin >> str[j];
    }
    str[j] = '\0';
    j = 0;
    while (str[j] != '\0') {
      if (str[j] != '0') {
        flag = 0;
        break;
      }
      flag = 1;
      j++;
    }
    j = 0;
    if (!flag) {
      while (str[j] != '\0') {
        if (str[j] == '0') {
          flag = 1;
          break;
        }
        j++;
      }
    }
    if (flag == 1) {
      ans++;
      res = ans;
    } else {
      res = ans;
      ans = 0;
    }
    flag = 0;
    if (res > max) max = res;
  }
  cout << max;
  return 0;
}
