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

char key[101] = {};
char code[101] = {};
char password[26] = {};

int main() {
    char result[101];
    uint32_t keyLen,codeLen,i,j;
    uint32_t passwordLen = 0;
    char alphabet;

    scanf("%s\n%s", key, code);
    keyLen = strlen(key);
    codeLen = strlen(code);
    for (i=0; i<keyLen; ++i) {    // 秘钥去重
        for (j=0; j<passwordLen; ++j) {
            if (key[i] == password[j]) {
                break;
            } else {}
        }
        if (j==passwordLen) {
            password[passwordLen] = key[i];
            ++passwordLen;
        } else {}
    }

    if (passwordLen<26) {    // 根据去重后的秘钥生成补全后的密码本
        for (alphabet='a'; alphabet<='z'; ++alphabet) {
            for (i=0; i<passwordLen; ++i) {
                if (alphabet == password[i]) {
                    break;
                } else {}
            }
            if (i==passwordLen) {
                password[passwordLen] = alphabet;
                ++passwordLen;
            } else {}
        }
    }

    for (i=0; i<codeLen; ++i) {    // 对照密码本生成加密后的字符串
        result[i] = password[code[i]-'a'];
    }

    for (i=0; i<codeLen; ++i) {    // 打印
        printf("%c", result[i]);
    }

    return 0;
}