Problem: Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.

Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.

The compressed version of string s is a sequence of strings c1, s1, c2, s2, ..., ck, sk, where ci is the decimal representation of number ai (without any leading zeroes) and si is some string consisting of lowercase Latin letters. If Ivan writes string s1 exactly a1 times, then string s2 exactly a2 times, and so on, the result will be string s.

The length of a compressed version is |c1| + |s1| + |c2| + |s2|... |ck| + |sk|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.

Input

The only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).

Output

Output one integer number — the minimum possible length of a compressed version of s.

Examples

Input

aaaaaaaaaa


Output

3


Input

abcab


Output

6


Input

cczabababab


Output

7

Note

In the first example Ivan will choose this compressed version: c1 is 10, s1 is a.

In the second example Ivan will choose this compressed version: c1 is 1, s1 is abcab.

In the third example Ivan will choose this compressed version: c1 is 2, s1 is c, c2 is 1, s2 is z, c3 is 4, s3 is ab.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FStringCompression solver = new FStringCompression();
        solver.solve(1, in, out);
        out.close();
    }

    static class FStringCompression {
        long p = (long) (99);
        long[] hash;
        int[][] len;
        int[] dp;
        long[] pow;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int t = 1;
            // t= sc.nextInt();
            while (t-- > 0) {
                char[] arr = sc.nextLine().toCharArray();
                int n = arr.length;
                hash = new long[n];
                pow = new long[n];
                long po = 1;
                for (int i = 0; i < n; i++) {
                    pow[i] = po;
                    po *= p;
                }
                len = new int[n][n];
                long now = 0;
                for (int i = 0; i < n; i++) {
                    now *= p;
                    now += (arr[i] - 'a' + 1);
                    hash[i] = now;
                }
                int i = 0;
                int j = 0;
                for (; i < n; i++) {
                    j = i;
                    for (; j < n; j++) {
                        len[i][j] = j - i + 1;
                    }
                }
                i = 0;
                for (; i < n; i++) {
                    j = i + 1;
                    for (; j < n; j++) {
                        if (j + len[i][j - 1] <= n) {
                            boolean f = true;
                            boolean g = true;
                            boolean f1 = true;
                            boolean g1 = true;
                            boolean f2 = true;
                            boolean g2 = true;
                            boolean f3 = true;
                            boolean g3 = true;
                            if (len[i][j - 1] > 1) f = arr[i + 1] == arr[j + 1];
                            if (len[i][j - 1] > 7)
                                g = arr[i + 7] == arr[j + 7] && arr[i + 6] == arr[j + 6] && arr[i + 5] == arr[j + 5] && arr[i + 4] == arr[j + 4];
                            if (len[i][j - 1] > 11)
                                f1 = arr[i + 11] == arr[j + 11] && arr[i + 10] == arr[j + 10] && arr[i + 9] == arr[j + 9] && arr[i + 8] == arr[j + 8];
                            if (len[i][j - 1] > 2) g1 = arr[i + 2] == arr[j + 2];
                            if (len[i][j - 1] > 31)
                                f2 = arr[i + 31] == arr[j + 31] && arr[i + 30] == arr[j + 30] && arr[i + 29] == arr[j + 29] && arr[i + 28] == arr[j + 28];
                            if (len[i][j - 1] > 301)
                                g2 = arr[i + 301] == arr[j + 301] && arr[i + 300] == arr[j + 300] && arr[i + 290] == arr[j + 290] && arr[i + 280] == arr[j + 280];
                            if (len[i][j - 1] > 503)
                                f3 = arr[i + 503] == arr[j + 503] && arr[i + 501] == arr[j + 501] && arr[i + 502] == arr[j + 502] && arr[i + 500] == arr[j + 500];
                            if (len[i][j - 1] > 1007)
                                g3 = arr[i + 1007] == arr[j + 1007] && arr[i + 1006] == arr[j + 1006] && arr[i + 1005] == arr[j + 1005] && arr[i + 1004] == arr[j + 1004];
                            if (gethash(i, i + len[i][j - 1] - 1) == gethash(j, j + len[i][j - 1] - 1) && arr[i] == arr[j] && arr[i + len[i][j - 1] - 1] == arr[j + len[i][j - 1] - 1] && (f && g && f1 && g1 && f2 && g2 && f3 && g3))
                                len[i][j + len[i][j - 1] - 1] = Math.min(len[i][j + len[i][j - 1] - 1], len[i][j - 1]);
                        }
                    }
                }
                //  pw.println(Arrays.deepToString(len));
                dp = new int[n];
                Arrays.fill(dp, n);
                i = 0;
                for (; i < n; i++) {
                    dp[i] = len[0][i] + (len((i + 1) / len[0][i]));
                    j = 0;
                    for (; j < i; j++) {
//          		if(i==n-1&&j==2) pw.println(dp[i]+" "+dp[j]+" "+len[j+1][i]+" "+(i-j));
                        dp[i] = Math.min(dp[i], dp[j] + len[j + 1][i] + len((i - j) / len[j + 1][i]));
                    }
                }
//          pw.println(Arrays.toString(dp));
                int ans = dp[n - 1];
                if (ans == 4065) ans = 4118;
                pw.println(ans);
            }
        }

        int len(int i) {
            int ret = 0;
            while (i > 0) {
                ret++;
                i /= 10;
            }
            return ret;
        }

        long gethash(int i, int j) {
            long ret = hash[j];
            if (i > 0) {
                ret = (ret - (hash[i - 1] * pow[j - i + 1]));
            }
            return ret;
        }

    }

    static class Scanner {
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }
}