#include <bits/stdc++.h>
using namespace std;
int p[210000], pp[210000];
map<pair<int, int>, vector<int> > mp[210000];
map<pair<int, int>, vector<int> >::iterator it;
int calc(int u, int v) {
  if (u > v) return 0;
  int res = p[v];
  if (u) res -= (long long)p[u - 1] * pp[v - u + 1] % 1000000007;
  if (res < 0) res += 1000000007;
  return res;
}
char s[210000];
int main() {
  int n, i, ans;
  cin >> n >> s;
  for (i = 0; i < n; i++)
    p[i] = (s[i] - 'a' + 1 + (i ? (long long)p[i - 1] * 29 : 0)) % 1000000007;
  for (pp[0] = i = 1; i <= n; i++)
    pp[i] = (long long)pp[i - 1] * 29 % 1000000007;
  for (i = 0; i < n; i++) mp[1][pair<int, int>(calc(i, i), 1)].push_back(i);
  ans = 0;
  for (i = 1; i <= n; i++)
    if (mp[i].size()) {
      ans = i;
      for (it = mp[i].begin(); it != mp[i].end(); it++) {
        int len = it->first.second;
        vector<int> id = it->second, mid;
        for (int sz = id.size(), j = 0; j < sz - 1; j++) {
          mid.push_back(calc(id[j] + len, id[j + 1] - 1));
        }
        for (int sz = mid.size(), j = 0, k = 0; j < sz; j = k) {
          while (k < sz && mid[j] == mid[k]) k++;
          mp[i + k - j]
            [pair<int, int>(calc(id[j], id[k] + len - 1), id[k] - id[j] + len)]
                .push_back(id[j]);
        }
      }
    }
  printf("%d\n", ans);
  return 0;
}
