#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5 + 5);
const int INF = 1e9 + 7;
const long long inf = 1e18;
int n, m;
int main() {
  cin >> n >> m;
  int cur = 0, ans = 0;
  for (int i = 1; i <= m; ++i) {
    char ch;
    set<char> st;
    for (int j = 1; j < 2; ++j) {
      string s;
      cin >> s;
      st.insert(s.begin(), s.end());
      ch = s[0];
    }
    if (st.size() == 1) {
      if (ch == '1') {
        ans = max(ans, cur);
        cur = 0;
      } else {
        ++cur;
      }
    } else {
      ++cur;
    }
  }
  ans = max(ans, cur);
  cout << ans;
  return 0;
}
