#include <bits/stdc++.h>
using namespace std;
int check(char a) {
  if ((int)a < 123 && (int)a > 96)
    return true;
  else
    return false;
}
char anticaps(char a) {
  int a1 = (int)a + 32;
  return a1;
}
int main() {
  string A;
  int tmp = 0;
  getline(cin, A);
  for (int i(0); i < A.length(); i++)
    if (!check(A[i])) tmp++;
  if (A.length() == tmp)
    for (int i(0); i < A.length(); i++) cout << anticaps(A[i]);
  else if (check(A[0]) && A.length() - 1 == tmp) {
    A[0] = (int)A[0] - 64;
    for (int i(0); i < A.length(); i++) cout << anticaps(A[i]);
  } else
    for (int i(0); i < A.length(); i++) cout << A[i];
}
