#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200005, P = 1000000009, B = 317;
char s[N];
int n, tt[N];
ll pw[N], val[N];
map<pair<int, int>, vector<int>> mp[N];
inline ll hs(int l, int r) {
  return (val[r] - val[l - 1] * pw[r - l + 1] % P + P) % P;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> (s + 1);
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * B % P;
  for (int i = 1; i <= n; i++)
    val[i] = (val[i - 1] * B + s[i] - 'a' + 19260817) % P;
  for (int i = 1; i <= n; i++) mp[1][{hs(i, i), 1}].push_back(i);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (mp[i].empty()) continue;
    ans = i;
    for (auto &j : mp[i]) {
      auto &v = j.second;
      int len = j.first.second;
      for (int k = 0; k < int(v.size()) - 1; k++)
        tt[k] = hs(v[k], v[k + 1] - 1);
      for (int l = 0, r = 1; l < int(v.size()) - 1; l = r++) {
        while (r < int(v.size()) - 1 && tt[r - 1] == tt[r]) ++r;
        mp[i + r - l][{hs(v[l], v[r] + len - 1), v[r] + len - v[l]}].push_back(
            v[l]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
