#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, vector<int> > f[200010];
int Base[200010], num[200010];
int Hash(int l, int r) {
  return (num[r] - (long long)num[l - 1] * Base[r - l + 1] % 1000000007 +
          1000000007) %
         1000000007;
}
int n, ans, q[200010];
char s[200010];
int main() {
  scanf("%d%s", &n, s + 1);
  Base[0] = 1;
  for (int i = 1; i <= n; i++) {
    num[i] = ((long long)num[i - 1] * 2333 + s[i]) % 1000000007;
    Base[i] = (long long)Base[i - 1] * 2333 % 1000000007;
  }
  for (int i = 1; i <= n; i++) f[1][make_pair(s[i], 1)].push_back(i);
  for (int i = 1; i <= n; i++)
    if (!f[i].empty()) {
      ans = i;
      for (auto &it : f[i]) {
        int len = it.first.second;
        vector<int> a = it.second;
        int m = a.size() - 1;
        for (int j = 0; j < m; j++) q[j] = Hash(a[j] + len, a[j + 1] - 1);
        for (int l = 0, r = 1; l < m; l = r, r++) {
          while (r < m && q[r - 1] == q[r]) r++;
          pair<int, int> t =
              make_pair(Hash(a[l], a[r] + len - 1), a[r] - a[l] + len);
          f[i + r - l][t].push_back(a[l]);
        }
      }
    }
  printf("%d\n", ans);
  return 0;
}
