#include <stdio.h>

int pnt;
char str[100000];

struct TR
{
	int k;
	TR *ref[9];

	void out()
	{
		if (k == 0) printf("a");
		else
		{
			for (int i = 0; i < k; i++) ref[i]->out();
			printf("%d", k);
		}
	}
};

TR tree[100000];
int ntree;

int nstack;
int ref[100000], a[100000];
int na;
char ts[100000];

int main()
{
	int i, j, k, L, b, c, kk;
	freopen("chandelier.in", "rt", stdin);
	freopen("chandelier.out", "wt", stdout);
	scanf("%s", str);
	ntree = 0; na = 0; pnt = 0;
	for (pnt = 0; str[pnt]; pnt++)
	{
		if (str[pnt] >= '1' && str[pnt] <= '9')
		{
			L = str[pnt] - '0'; c = 1000000; kk = 0;
			for (k = 0; k < L; k++)
			{
				b = 0;
				for (i = 0; i < L; i++)
				{
					j = na - L + (k + i) % L;
					if (a[j] + i >= b) b = a[j] + i;
				}
				if (c > b) {c = b; kk = k;}
			}
			na -= L;
			tree[ntree].k = L;
			for (i = 0; i < L; i++)
			{
				tree[ntree].ref[i] = &tree[ref[na + (i+kk) % L]];
			}
			ref[na] = ntree; a[na] = c;
			ntree++;
			na++;
		}
		else
		{
			ref[na] = ntree; a[na] = 1;
			tree[ntree++].k = 0;
			na++;
		}
	}
	printf("%d\n", a[na-1]);
	tree[ntree-1].out();
	printf("\n");
	return 0;
}
