#include<cstdio>
#include<cstring>
#define isA(a) (a>='a'&&a<='z')
char CUV[20001][21],FL[20001][2];
int LM[250],LI[20001],PM[250],PI[20001];
int N=1,maxs,sts;
void read(),solve(),show();
int main()
{
	read();
	solve();
	show();
	return 0;
}
void read()
{
	int LN=0;
	char c;
	freopen("text3.in","r",stdin);
	freopen("text3.out","w",stdout);
	while(scanf("%c",&c)!=-1)
	{
		if(isA(c)) CUV[N][LN++]=c;
		else 
		{
			if(LN)
			{
				FL[N][1]=CUV[N][LN-1];
				FL[N][0]=CUV[N][0];
				N++;
				LN=0;
			}
		}
	}
}
void solve()
{
	int i;
	N--;
	for(i=1;i<=N;i++)
	{
		LI[i]=LM[FL[i][0]]+1;
		PI[i]=PM[FL[i][0]];
		if(LI[i]>LM[FL[i][1]])
		{
			LM[FL[i][1]]=LI[i];
			PM[FL[i][1]]=i;
		}	
	}
	for(i='a';i<='z';i++)
	{
		if(LM[i]>maxs)
		{
			maxs=LM[i];
			sts=PM[i];
		}
	}
	printf("%d\n%d\n",N,N-maxs);
}
void show()
{
	int i=sts;
	while(PI[i]) LI[PI[i]]=i,i=PI[i];
	
	while(i!=sts) printf("%s\n",CUV[i]),i=LI[i];
	
	printf("%s\n",CUV[sts]);
}