#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int maxn = 110;
int n;
int a[maxn][maxn];
int res[maxn][maxn];
bool vis[maxn];
int ans, cnt;
void dfs(int u) {
  vis[u] = 1;
  cnt++;
  ans = max(ans, cnt);
  for (int i = 0; i < n; i++) {
    if (!res[u][i] && !vis[i]) {
      dfs(i);
    }
  }
}
void solve() {
  memset(res, 0, sizeof(res));
  memset(vis, 0, sizeof(vis));
  scanf("%d", &n);
  char s[maxn];
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < n; j++) a[i][j] = s[j] - '0';
    res[i][i] = 1;
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (a[i][k] != a[j][k]) res[i][j] = res[j][i] = 1;
  ans = INT_MIN;
  for (int i = 0; i < n; i++) {
    cnt = 0;
    if (!vis[i]) dfs(i);
  }
  printf("%d", ans);
}
int main() {
  solve();
  return 0;
}
