#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;
int main() {
string input;
getline(cin, input);
string word = "";
string result = "";
for (int i = input.size() - 1; i >= 0; i--) {
if (input[i] == ' ') {
if (!word.empty()) {
for (char &c : word) {
if (islower(c)) {
c = toupper(c);
} else if (isupper(c)) {
c = tolower(c);
}
}
result += word + " ";
word = "";
}
} else {
word = input[i] + word;
}
}
if (!word.empty()) {
for (char &c : word) {
if (islower(c)) {
c = toupper(c);
} else if (isupper(c)) {
c = tolower(c);
}
}
result += word;
}
cout << result << endl;
return 0;
}