#include <bits/stdc++.h>
using namespace std;
int main() {
  string word;
  cin >> word;
  int counter = 0, counter2 = 0, counter3 = 0, counter4 = 0;
  for (int x = 0; x < word.length(); x++) {
    if (isupper(word.at(x))) {
      counter++;
    }
  }
  for (int x = 0; x < word.length(); x++) {
    if (x == 0) {
      if (islower(word.at(x))) {
        counter2++;
      }
    } else {
      if (isupper(word.at(x))) {
        counter3++;
      }
    }
  }
  if (counter == word.length()) {
    for (int x = 0; x < word.length(); x++) {
      word.at(x) = tolower(word.at(x));
    }
    cout << word;
  } else if (counter2 == 1 && counter3 == word.length() - 1) {
    for (int x = 0; x < word.length(); x++) {
      if (x == 0)
        word.at(x) = toupper(word.at(x));
      else
        word.at(x) = tolower(word.at(x));
    }
    cout << word;
  } else
    cout << word;
}
