#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[]){

	char key[20], type, input[2048], output[2048];
	scanf("%c\n%s\n%s",&type, key, input); 
	int key_len = strlen(key);

	if(type == 'e'){
		int i = 0, j = 0; 
		for(; input[i]!= '\0'; i++){
			output[i] = input[i] + key[j++ % key_len] - 'A';
			if (output[i] > 'Z')
				output[i] = output[i] - 'Z' - 1 + 'A';
		}
		output[i] = '\0';
	}

	else if(type == 'd'){
		int i = 0, j = 0;
		for(; input[i]!= '\0'; i++){
			output[i] = input[i] - key[j++ % key_len] + 'A';
			if (output[i] < 'A')
				output[i] = 'Z' - ('A' - output[i] - 1);
		}
		output[i] = '\0';
	}
	
	printf("%s\n", output);

	return 0;
}
