#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

int GetNumberLength( int number ) {
    int result = 0;
    if( number == 0 ) {
        return 1;
    }
    while( number != 0 ) {
        number /= 10;
        result++;
    }
    return result;
}

const int MaxN = 1000;
int commonPref[MaxN+1][MaxN+1];
int best[MaxN+1];
int backLinks[MaxN+1];
int repeatCounts[MaxN+1];

string IntToString( int number ) {
    string result("");
    while( number != 0 ) {
        result = string("") + (char)(number % 10 + '0') + result;
        number /= 10;
    }
    return result;
}

int main() {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    string inp;
    char buffer[1024];
    cin.getline(buffer,1024);
    inp = buffer;
    int n = inp.length();
    // Calculating common prefixes
    for( int diff = 1; diff < n; diff++ ) {
        int index = 0;
        while( index + diff < n ) {
            int length = 0;
            while( diff + index + length < n && inp[index+length] == inp[index+diff+length] ) {
                length++;
            }
            for( int i = 0; i < length; i++) {
                commonPref[index+i][index+i+diff] = length - i;
            }
            index += length+1;
        }
    }

    // initializing
    for( int i = 0; i <= n; i++) {
        best[i] = MaxN + 1;
        backLinks[i] = -1;
    }
    best[0] = 0;

    // Dyn. prog.
    for( int i = 0; i < n; i++) {
        for( int j = i+1; j <= n; j++ ) {
            int maxCount = commonPref[i][j] / (j-i) + 1;
            for( int repeatCount = 1; repeatCount <= maxCount; repeatCount++ ) {
                if( best[i+(j-i)*repeatCount] > best[i] + j - i + GetNumberLength(repeatCount) ) {
                    best[i+(j-i)*repeatCount] = best[i] + j - i + GetNumberLength(repeatCount);
                    backLinks[i+(j-i)*repeatCount] = i;
                    repeatCounts[i+(j-i)*repeatCount] = repeatCount;
                }
            }
        }
    }

    // Printing answer
    string res = "";
    int index = n;
    while( index != 0 ) {
        int repeatCount = repeatCounts[index];
        int length = (index - backLinks[index]) / repeatCount;
        index = backLinks[index];
        res = string("") + inp.substr(index, length) + IntToString(repeatCount) + res;
    }
    cout << res;

    return 0;
}
