//先去重获得秘钥然后进行二次去重获取字典,使用asc码差值获取字母位置
while(key = readline()) {
const newStr = Array.from(new Set(key.split(''))).join('').toLowerCase();
const book = newStr + 'abcdefghijklmnopqrstuvwxyz';
const bookList = Array.from(new Set(book.split('')));
const passStr = readline().split('');
let result = [];
for (let char of passStr) {
let code = char.charCodeAt();
if (code >=65 && code <= 90) {
let index = code - 65;
let str = bookList[index].toUpperCase();
result.push(str);
} else if (code >=97 && code <= 122) {
let index = code - 97;
result.push(bookList[index]);
} else {
let str = String.fromCharCode(code);
result.push(str);
}
}
print(result.join(''));
}