import java.util.*;
import java.io.*;
public class Main{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException {
String[] S = br.readLine().split(" ");
StringBuilder result = new StringBuilder();
for(int i = S.length - 1 ; i >= 0 ; i--) {
String str = S[i];
char c = str.charAt(0);
if(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') {
for(int j = 0 ; j < str.length(); j++) {
char ch = str.charAt(j);
if(ch >= 'a' && ch <= 'z') {
ch -= 32;
}
else if(ch >= 'A' && ch <= 'Z') {
ch += 32;
}
result.append(ch);
}
}
else {
for(int j = str.length() - 1 ; j >= 0 ;j--) {
result.append(str.charAt(j));
}
}
result.append(" ");
}
out.write(result.toString());
out.flush();
out.close();
br.close();
}
}