#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int MOD = 1000000007;
struct Int {
  int num;
  Int(long long int x) : num((x % MOD + MOD) % MOD) {}
  Int(int x) : num((x % MOD + MOD) % MOD) {}
  Int() : num(0) {}
  explicit operator int&() { return num; }
  Int& operator+=(Int x) {
    num = (num + x.num) % MOD;
    return *this;
  }
  Int operator+(Int x) {
    Int ret((num + x.num) % MOD);
    return ret;
  }
  Int& operator-=(Int x) {
    num = ((num - x.num) % MOD + MOD) % MOD;
    return *this;
  }
  Int operator-(Int x) {
    Int ret(((num - x.num) % MOD + MOD) % MOD);
    return ret;
  }
  Int& operator*=(Int x) {
    num = (1ll * num * x.num) % MOD;
    return *this;
  }
  Int operator*(Int x) {
    Int ret((1ll * num * x.num) % MOD);
    return ret;
  }
};
const int N = 200005;
const Int P = 13131;
Int pw[N];
void init() {
  pw[0] = 1;
  for (int i = 1; i < N; i++) pw[i] = pw[i - 1] * P;
}
Int hsh[N];
int get(int l, int r) {
  if (l > r) return 0;
  return (int)(hsh[r + 1] - hsh[l] * pw[r - l + 1]);
}
char second[N];
map<pair<int, int>, vector<int>> dp[N];
int main() {
  init();
  int n;
  scanf("%d%s", &n, second);
  hsh[0] = 0;
  for (int i = 1; i <= n; i++) hsh[i] = hsh[i - 1] * P + second[i - 1];
  for (int i = 0; i < n; i++) dp[0][pair<int, int>(get(i, i), 1)].push_back(i);
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (dp[i].size()) {
      ans = i + 1;
      for (auto& x : dp[i]) {
        vector<int>& ve = x.second;
        sort(ve.begin(), ve.end());
        ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
        int sz = ve.size();
        if (sz <= 1) continue;
        int pre = get(ve[0] + x.first.second, ve[1] - 1), now;
        for (int l = 0, r = 0; l + 1 < sz; l = r) {
          while (r + 1 < sz &&
                 pre == (now = get(ve[r] + x.first.second, ve[r + 1] - 1)))
            r++;
          dp[i + r - l][pair<int, int>(get(ve[l], ve[r] + x.first.second - 1),
                                       ve[r] - ve[l] + x.first.second)]
              .push_back(ve[l]);
          pre = now;
        }
      }
    }
  printf("%d\n", ans);
}
