using System;
using System.IO;
using System.Linq;

namespace ConsoleApp4
{
    class Program
    {
        static void Main()
        {
            var A = Console.ReadLine();
            var S = Console.ReadLine();
            var _tmp = new List<char>();

            foreach(var s in S)
            {
                if ( s >= '0' && s <= '9')
                {
                    var sInt = int.Parse(s.ToString());
                    _tmp.Add(A[sInt]);
                }
                else
                {
                    _tmp.Add(s);
                }
            }
            Console.WriteLine(String.Join("", _tmp));
        }
    }
}