#include <bits/stdc++.h>
namespace IO {
char buf[1 << 20 | 1], *f1 = buf, *f2 = buf, pbuf[1 << 24 | 1], *f3 = pbuf,
                       sta[100];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
template <class T>
inline void write(T x) {
  if (!x) return (void)(*f3++ = 48, *f3++ = ' ');
  if (x < 0) *f3++ = '-', x = ~x + 1;
  char *top = sta;
  while (x) *top++ = x % 10 + 48, x /= 10;
  while (top != sta) *f3++ = *--top;
  *f3++ = ' ';
}
inline void put(std::string s) {
  int len = s.length();
  for (int i = 0; i < len; i++) *f3++ = s[i];
  *f3++ = ' ';
}
inline void endline() { *f3++ = '\n'; }
template <class T>
inline T abs(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline void swap(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
}  // namespace IO
using namespace IO;
const int N = 2e5 + 5, base = 317, mod = 1e9 + 713;
int n, ans;
char s[N];
int b[N], h[N], q[N];
std::map<std::pair<int, int>, std::vector<int> > f[N];
inline int Hash(int l, int r) {
  return (h[r] - 1ll * h[l - 1] * b[r - l + 1] % mod + mod) % mod;
}
int main() {
  n = read();
  scanf("%s", s + 1);
  b[0] = 1;
  for (int i = 1; i <= n; i++) {
    h[i] = (1ll * h[i - 1] * base + s[i]) % mod;
    b[i] = 1ll * b[i - 1] * base % mod;
  }
  for (int i = 1; i <= n; i++) f[1][std::make_pair(s[i], 1)].push_back(i);
  for (int i = 1; i <= n; i++)
    if (!f[i].empty()) {
      ans = i;
      std::map<std::pair<int, int>, std::vector<int> >::iterator it;
      for (it = f[i].begin(); it != f[i].end(); it++) {
        int len = it->first.second;
        std::vector<int> v = it->second;
        int m = v.size() - 1;
        for (int j = 0; j < m; j++) q[j] = Hash(v[j] + len, v[j + 1] - 1);
        for (int l = 0, r = 1; l < m; l = r, r++) {
          while (r < m && q[r] == q[r - 1]) r++;
          f[i + r - l]
           [std::make_pair(Hash(v[l], v[r] + len - 1), v[r] - v[l] + len)]
               .push_back(v[l]);
        }
      }
    }
  printf("%d\n", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
