#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  string check = str;
  transform(check.begin(), check.end(), check.begin(), ::toupper);
  if (check == str) {
    for (int i = 0; i < str.size(); i++) {
      char ch = tolower(str[i]);
      cout << ch;
    }
    cout << endl;
    return 0;
  } else {
    bool flag = false;
    char ch1 = tolower(str[0]);
    if (ch1 == str[0]) {
      for (int i = 1; i < str.size(); i++) {
        char ch2 = toupper(str[i]);
        if (str[i] == ch2) {
          continue;
        } else {
          flag = true;
        }
      }
      if (flag == false) {
        char ch3 = toupper(str[0]);
        cout << ch3;
        for (int i = 1; i < str.size(); i++) {
          char ch4 = tolower(str[i]);
          cout << ch4;
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << str << endl;
}
