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

char* type;
char* input;
char* key;
char* output;

int getCharIndex(char inputChar) {
    if(isupper(inputChar)) {
        return inputChar - 65;
    } else if(islower(inputChar)) {
        return inputChar - 97;
    }
}

char* encrypt(char* key, char* input) {
    int iplen = strlen(input);
    int keylen = strlen(key);
    for(int i = 0; i<iplen; i++) {
        output[i] = ((getCharIndex(input[i]) + getCharIndex(key[i % keylen]))% 26);
        if(isupper(input[i])) {
            output[i] = output[i] + 65;
        } else 
            output[i] = output[i] + 97;
    }
    return output;
}

char* decrypt(char* key, char* input) {
    int iplen = strlen(input);
    int keylen = strlen(key);
    for(int i = 0; i<iplen; i++) {
        output[i] = ((getCharIndex(input[i]) - getCharIndex(key[i % keylen]))% 26);
        if(output[i] < 0)
            output[i] += 26;
        if(isupper(input[i])) {
            output[i] = output[i] + 65;
        } else 
            output[i] = output[i] + 97;
    }
    return output;
}

int main() {
    type = (char *)malloc(sizeof(char));
    input = (char *)malloc(sizeof(char)*1024);
    output = (char *)malloc(sizeof(char)*1024);
    key = (char *)malloc(sizeof(char)*1024);

    scanf("%[^\n]\n",type);
    scanf("%[^\n]\n",key);
    scanf("%[^\n]",input);

    if(strcmp(type,"e")==0 || strcmp(type,"E") == 0) {
       output =  encrypt(key,input);
    }
    else if(strcmp(type,"d") == 0 || strcmp(type,"D") == 0)
            output = decrypt(key,input);
    printf("%s",output);
}