#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool cmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   const int N = 444444;   int fa[N], ch[N][26], l[N], f[N], a[N], c[N], pos[N], top[N];   char s[N];   int last = 1, cnt = 1, n, ans = 1;   void ins(int c, int k) {     int p = last, np = ++cnt;     last = np, l[np] = l[p] + 1, pos[np] = k;     for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;     if (!p)       fa[np] = 1;     else {       int q = ch[p][c];       if (l[q] == l[p] + 1)         fa[np] = q;       else {         int nq = ++cnt;         l[nq] = l[p] + 1, pos[nq] = pos[q];         memcpy(ch[nq], ch[q], sizeof(ch[q]));         fa[nq] = fa[q], fa[np] = fa[q] = nq;         for (; ch[p][c] == q; p = fa[p]) ch[p][c] = nq;       }     }   }   void calc() {     for (int i = 1; i <= cnt; ++i) ++c[l[i]];     for (int i = 1; i <= cnt; ++i) c[i] += c[i - 1];     for (int i = 1; i <= cnt; ++i) a[c[l[i]]--] = i;   }   int L[N * 25], R[N * 25], rt[N], tot;   void modify(int &now, int l, int r, int x) {     now = ++tot;     if (l == r) return;     int mid = l + r >> 1;     if (x <= mid)       modify(L[now], l, mid, x);     else       modify(R[now], mid + 1, r, x);   }   int merge(int x, int y) {     if (!x || !y) return x | y;     int z = ++tot;     L[z] = merge(L[x], L[y]);     R[z] = merge(R[x], R[y]);     return z;   }   int query(int x, int l, int r, int ql, int qr) {     if (!x) return 0;     if (ql <= l && qr >= r) return 1;     int mid = l + r >> 1;     if (ql <= mid && query(L[x], l, mid, ql, qr)) return 1;     if (qr > mid && query(R[x], mid + 1, r, ql, qr)) return 1;     return 0;   }   int main() {     scanf( %d , &n);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) ins(s[i] -  a , i), modify(rt[last], 1, n, i);     calc();     for (int i = cnt; i > 1; --i) rt[fa[a[i]]] = merge(rt[fa[a[i]]], rt[a[i]]);     for (int i = 2; i <= cnt; ++i) {       int u = a[i], ff = fa[u];       if (ff == 1) {         f[u] = 1, top[u] = u;         continue;       }       int x = query(rt[top[ff]], 1, n, pos[u] - l[u] + l[top[ff]], pos[u] - 1);       if (x)         f[u] = f[ff] + 1, top[u] = u;       else         f[u] = f[ff], top[u] = top[ff];       cmax(ans, f[u]);     }     printf( %d n , ans);     return 0;   }   