#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    char *buffer = NULL;
    size_t bufferSize = 0;
    size_t count = 0;
    char c;

    while(cin.get(c) && c != '\n')
    {
        // Resize the buffer if we need more space.
        if(count + 2 > bufferSize) // bufferSize includes null terminator.
        {
            // Store information about the original one.
            char *old = buffer;
            size_t oldSize = bufferSize;

            // Calculate new size.
            bufferSize = ((count + 2) / 5 + 1) * 5;
            cout << "current length : " << count << "  new size : " << bufferSize << endl;

            // Allocate using new size.
            buffer = new char[bufferSize];

            // Copy from the old one.
            memcpy(buffer, old, oldSize);

            delete [] old;
        }

        buffer[count] = c;
        ++count;
    }

    // Add null terminator.
    buffer[count] = '\0';

    cout << buffer << endl;

    return 0;
}