#include <bits/stdc++.h>
using namespace std;
int main() {
  int count = 0;
  string str;
  cin >> str;
  int n = str.length() - 1;
  for (int i = 1; i < str.length(); i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') count++;
  }
  if (count == n) {
    if (str[0] >= 'a' && str[0] <= 'z')
      str[0] = str[0] + ('A' - 'a');
    else if (str[0] >= 'A' && str[0] <= 'Z')
      str[0] = str[0] - ('A' - 'a');
    for (int k = 1; k < str.length(); k++) {
      str[k] = str[k] - ('A' - 'a');
    }
  }
  cout << str << endl;
  return 0;
}
