Problem:
Score : 200 points

Problem Statement

You are going to take the entrance examination of Kyoto University tomorrow
and have decided to memorize a set of strings S that is expected to appear in the examination.
Since it is really tough to memorize S as it is,
you have decided to memorize a single string T that efficiently contains all the strings in S.

You have already confirmed the following conditions for S and T are satisfied.

Every string in S is a consecutive subsequence(1) in T .

For every pair of strings x, y (x \neq y) in S ,
x is not a subsequence(2) of y.

Note that (1) is ''consecutive subsequence'', while (2) is ''subsequence''.

The next day, you opened the problem booklet at the examination
and found that you can get a full score only if you remember S.
However, You have forgot how to reconstruct S from T .
Since all you remember is that T satisfies the above conditions,
first you have decided to find the maximum possible number of elements in S .

Constraints

1 \leq |T| \leq 10^5

T consists of only lowercase letters.

Partial points

30 points will be awarded for passing the test set satisfying the condition: 1 \leq |T| \leq 50 .

Another 30 points will be awarded for passing the test set satisfying the condition: 1 \leq |T| \leq 10^3.

Input

The input is given from Standard Input in the following format:

T

The input only consists of T on one line.

Output

Print the maximum number of elements inS .

Sample Input 1

abcabc

Sample Output 1

3

In this case, ab，ca and bc are an example of the optimum answers.

Sample Input 2

abracadabra

Sample Output 2

7

Sample Input 3

abcbabbcabbc

Sample Output 3

8

Sample Input 4

bbcacbcbcabbabacccbbcacbaaababbacabaaccbccabcaabba

Sample Output 4

44

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cassert>

const int kN = (1 << 18) + 5;
int sa[kN],rank[kN],height[kN];
void construct(const char *s,int n,int m = 256) {
    static int t1[kN],t2[kN],c[kN];
    int *x = t1,*y = t2;
    int i,j,k,p,l;
    for (i = 0; i < m; ++ i) c[i] = 0;
    for (i = 0; i < n; ++ i) c[x[i] = s[i]] ++;
    for (i = 1; i < m; ++ i) c[i] += c[i - 1];
    for (i = n - 1; i >= 0; -- i) sa[--c[x[i]]] = i;
    for (k = 1; k <= n; k <<= 1) {
        p = 0;
        for (i = n - k; i < n; ++ i) y[p++] = i;
        for (i = 0; i < n; ++ i) if (sa[i] >= k) y[p++] = sa[i] - k;
        for (i = 0; i < m; ++ i) c[i] = 0;
        for (i = 0; i < n; ++ i) c[x[y[i]]] ++;
        for (i = 1; i < m; ++ i) c[i] += c[i - 1];
        for (i = n - 1; i >= 0; -- i) sa[--c[x[y[i]]]] = y[i];
        std::swap(x,y);
        p = 1; x[sa[0]] = 0;
        for (i = 1; i < n; ++ i) 
            x[sa[i]] = y[sa[i - 1]] == y[sa[i]] 
                && y[sa[i - 1] + k] == y[sa[i] + k] ? p - 1: p ++;
        if (p >= n) break;
        m = p;
    }
    for (i = 0; i < n; ++ i) rank[sa[i]] = i;
    for (i = 0,l = 0; i < n; ++ i) {
        if (rank[i]) {
            j = sa[rank[i] - 1];
            while (s[i + l] == s[j + l]) l++;
            height[rank[i]] = l;
            if (l) l--;
        }
    }
}

char t[kN];

int main() {
  scanf("%s", t);
  int n = strlen(t);
  construct(t, n);
  int mx = 0;
  for (int i = 0; i < n; ++ i)
    mx = std::max(mx, height[i]);
  printf("%d\n", n - mx);
}