import java.util.*;

/**
 * HJ36 字符串加密
 */
public class HJ036 {

    /**
     * 思路是利用有序的LinkedHashSet集合,先把密钥添加进去,再把剩下的字符添加进去形成完整的密钥;
     * 再根据要加密的字符串字符一个个取出拼接输出,ps:不要忘了大小写和空格
     */
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s1 = sc.nextLine().toUpperCase();
            String s2 = sc.nextLine();
            char[] chars1 = s1.toCharArray();
            char[] chars2 = s2.toCharArray();
            LinkedHashSet<Character> set = new LinkedHashSet();
            for (char value : chars1) {
                set.add(value);
            }
            int k = 0;
            while (set.size() < 26) {
                char a = (char) ('A' + k);
                set.add(a);
                k++;
            }
            ArrayList<Character> list = new ArrayList<>(set);
            StringBuffer sb = new StringBuffer();
            for (char value : chars2) {
                if (value == ' ') {
                    sb.append(value);
                } else if (value < 'a') {
                    int n = value - 'A';
                    char c = list.get(n);
                    sb.append(c);
                } else {
                    int n = value - 'a';
                    char c = (char) (list.get(n) + 'a' - 'A');
                    sb.append(c);
                }
            }
            System.out.println(sb.toString());
        }
        sc.close();
    }
}