#include <stdio.h>
#include <stdlib.h>

void cenzurisi(char *pokmin, char c, char d)
{
    while(*pokmin || *pokmin==d)
    {
        if(*pokmin==c) *pokmin='*';
        pokmin++;
    }
}
int main()
{
    int min=200000,k=1,d;
    char tmp, minc, text[200000], rec[10];
    char *pok1, *pok2, *pok3, *pokmin, *gets();

    pok1 = gets(text);
    pok2 = gets(rec);
    tmp=*pok2;

    pok3=pok1;

    while(*pok1)
        {

        if(*pok1==*pok2)
            {printf("%d",k);

             if(min>k) {
             min=k, pokmin=pok3,k=1;

             minc = tmp;
             tmp = *pok1;
             pok3=pok1;
             d=*pok1;

             pok2++;
                }
            }
             else if(tmp == *pok1) k++;

            pok1++;
        }

    cenzurisi(pokmin, minc,d);
    printf("%s", text);

    return 0;
}