We call a sequence of strings t1, ..., tk a journey of length k, if for each i > 1 ti is a substring of ti - 1 and length of ti is strictly less than length of ti - 1. For example, {ab, b} is a journey, but {ab, c} and {a, a} are not.

Define a journey on string s as journey t1, ..., tk, such that all its parts can be nested inside s in such a way that there exists a sequence of strings u1, ..., uk + 1 (each of these strings can be empty) and s = u1 t1 u2 t2... uk tk uk + 1. As an example, {ab, b} is a journey on string abb, but not on bab because the journey strings ti should appear from the left to the right.

The length of a journey on a string is the number of strings in it. Determine the maximum possible length of a journey on the given string s.

Input

The first line contains a single integer n (1 ≤ n ≤ 500 000) — the length of string s.

The second line contains the string s itself, consisting of n lowercase Latin letters.

Output

Print one number — the maximum possible length of string journey on s.

Examples

Input

7
abcdbcc


Output

3


Input

4
bbcb


Output

2

Note

In the first sample, the string journey of maximum length is {abcd, bc, c}.

In the second sample, one of the suitable journeys is {bb, b}.
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
unsigned long long e = 1e6 + 3, pw[500005], calc[500005];
string st;
int n, m, i, j, dp[500005], ans;
char ss[500005];
set<unsigned long long> s[500005];
unsigned long long itcalc(int x, int y) {
  return calc[y] - calc[x - 1] * pw[y - x + 1];
}
bool check(int x) {
  return s[dp[x] - 1].count(itcalc(x, x + dp[x] - 2)) ||
         s[dp[x] - 1].count(itcalc(x + 1, x + dp[x] - 1));
}
int main() {
  scanf("%d %s", &n, ss);
  st = ss;
  st = " " + st;
  pw[0] = 1;
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    pw[i] = pw[i - 1] * e;
    calc[i] = calc[i - 1] * e + st[i];
  }
  for (((i)) = ((n)); ((i)) >= (1); ((i))--) {
    dp[i] = dp[i + 1] + 1;
    while (dp[i] > 1 && !check(i)) {
      dp[i]--;
      for (((j)) = ((dp[i + dp[i]])); ((j)) >= (1); ((j))--) {
        if (s[j].count(itcalc(i + dp[i], i + dp[i] + j - 1))) break;
        s[j].insert(itcalc(i + dp[i], i + dp[i] + j - 1));
      }
    }
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}
