#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

FILE* in=fopen("chandelier.in","r");
//FILE* in=stdin;
FILE* out=fopen("chandelier.out","w");
//FILE* out=stdout;

const long N=11000;

char s[N];
char r[N];


struct ch {
	char s[N];
	long st,l;
};

bool operator<(const ch& a, const ch& b) {
	return a.st>b.st;
}

struct tree {
	long a,b;
	long l;
	long st;
};

ch g[11];

long rec(long f, long& l) {
	if (s[f]=='a') {
		l=1;
		return 1;
	}

	long y=s[f]-'0';
	long k,c=1;

	tree a[10];

	long i;
	for (i=0; i<y; i++) {
		a[i].st=rec(f-c,k);
		a[i].b=f-c;
		c+=k;
		a[i].a=f-c+1;
		a[i].l=a[i].b-a[i].a+1;
	}
	for (i=0; i<y; i++) {
		strncpy(g[i].s,s+a[i].a,a[i].l);
		g[i].s[a[i].l]=0;
		g[i].st=a[i].st;
		g[i].l=a[i].l;
	}

	long h,bh,min=100000,cc,beg,j;
	for (h=0; h<y; h++) {
		beg=(y-h)%y;
		j=(beg+1)%y;
		cc=a[beg].st;
		k=2;
		for (;j!=beg;) {
			if (cc<=a[j].st+k)
				cc=a[j].st+k;
			k++;
			j=(j+1)%y;
		}
		if (cc<min) {
			bh=h;
			min=cc;
		}
	}
	h=bh;

	long sm=a[y-1].a;
	for (i=0; i<y; i++) {
		strncpy(s+sm,g[(i+y-h)%y].s,g[(i+y-h)%y].l);
		sm+=g[(i+y-h)%y].l;
	}

	l=c;
	return min;
}

int main()
{
	fscanf(in,"%s",s);
	long l=strlen(s);
	long i;
	long t=rec(l-1,i);
	fprintf(out,"%ld\n",t);
	fprintf(out,"%s\n",s);

	return 0;
}