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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class F {
    static char[] s;
    static int n;
    static int[] memo;
    static int times[][];
    static int dp (int idx) {
        if (idx == n) return 0;
        if (memo[idx] != -1) return memo[idx];
        ArrayList<Character> soFar = new ArrayList<>();
        int res = n + 3;

        for (int end = idx; end < n; end++) {
            soFar.add(s[end]);
            int lenOne = (end - idx + 1) / times[idx][end];
            res = Math.min(res, len(times[idx][end]) + lenOne + dp(end + 1));
        }
        return memo[idx] = res;
    }

    static int len (int num) {
        int res = 0;
        while (num > 0) {
            res++;
            num /= 10;
        }
        return res;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        s = sc.next().toCharArray();
        n = s.length;
        times = new int[n][n];
        ArrayList<Character> c = new ArrayList<>();
        for (int i = n - 1; i >= 0; i--){
            c.add(s[i]);
            kmpPreProcess(c, i);
        }

        memo = new int[n];
        Arrays.fill(memo, - 1);

        out.println(dp(0));
        out.flush();
        out.close();
    }

    public static void kmpPreProcess(ArrayList<Character> c, int start)
    {
        char[] P = new char[c.size()];
        for (int i = 0; i < c.size(); i++)
            P[i] = c.get(c.size() - 1 - i);
        int m = P.length;
        int[] b = new int[m + 1];
        int i = 0, j = -1; b[0] = -1;
        while(i < m)
        {
            while(j >= 0 && P[i] != P[j]) j = b[j];
            i++; j++;
            b[i] = j;
            int lenSoFar = i;
            times[start][start + i - 1] = (lenSoFar % (lenSoFar - b[lenSoFar])) == 0 ? lenSoFar / (lenSoFar - b[lenSoFar]) : 1;
        }
    }






















    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}