#include <iostream>
#include <string>
using namespace std;
int main() {
string mode;
string text;
int k;
cin >> mode;
cin >> k;
cin.ignore();
getline(cin, text);
for (int i = 0; i < text.size(); i++) {
char c = text[i];
if (c >= 'A' && c <= 'Z') {
if (mode == "szyfruj")
text[i] = 'A' + (c - 'A' + k) % 26;
else
text[i] = 'A' + (c - 'A' - k) % 26;
}
else if (c >= 'a' && c <= 'z') {
if (mode == "szyfruj")
text[i] = 'a' + (c - 'a' + k) % 26;
else
text[i] = 'a' + (c - 'a' - k + 26) % 26;
}
}
cout << text << endl;
return 0;
}