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

#define INCREMENT_SIZE 10

int main(void) {
	char* buffer = (char*)malloc(sizeof(INCREMENT_SIZE + 1));
	char* current = buffer;
	char ch;
	int length = 0;
	int maxLength = strlen(buffer);
	
	while (1)
	{
		ch = getchar();
		if (ch == '\n')
			break;
			
		if (++length >= maxLength)
		{
			char* newBuffer = realloc(buffer, maxLength + INCREMENT_SIZE);
			
			if (newBuffer == NULL) 
			{
				free(buffer);
				return 0;
			}
			
			maxLength += INCREMENT_SIZE;
			current = newBuffer + (current - buffer);
			buffer = newBuffer;
		}
		
		*current++ = ch;
	}
	
	*current = '\0';
	printf("%s\n", buffer);
	printf("%d\n", strlen(buffer));
	
	return 0;
}
