#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, res = 0;
  cin >> n >> m;
  int r = 0;
  while (m-- > 0) {
    bool flag = false;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i)
      if (s[i] == '0') {
        flag = true;
        break;
      }
    if (flag)
      r++;
    else
      r = 0;
    res = max(r, res);
  }
  cout << res;
}
