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

int provera_subsekvenci(char a[], char b[]);

main()
{
	char T[200000];
	gets(T);
	int N = strlen(T);
	
	char S[10];
	gets(S);
	int M = strlen(S);
	
	int p;
	if (M < N) p = provera_subsekvenci(S, T);
	
	if (p == 1)
	{
		int min = 0, f[256] = {0}, i;
		scanf("%d", &min);
		int min_original = min;
		
		for (i = 0; i < N; i++) f[T[i]]++;
		
		for (i = 0; i < 256; i++)
		{
			if (f[i] != 0)
			{
				if(f[i] == min) min = i;
			}
		}
	
		if (min != min_original)
		{
			for (i = 0; i < N; i++)
			{
				if (T[i] == min) T[i] = '*';
			}
		
			printf("%d\n", p);
			printf("%s", T);	
		}
	}
}

int provera_subsekvenci(char a[], char b[])
{
	int c = 0, d = 0;
	
	while (a[c] != '\0')
	{
		while ((a[c] != b[d]) && b[d] != '\0') d++;
			
		if (b[d] == '\0') break;
		d++;
		c++;
	}
		
	if (a[c] == '\0') return 1;
}