#include <bits/stdc++.h>
int main() {
  std::string s;
  std::cin >> s;
  if (s.size() == 1) {
    if (std::islower(s[0])) {
      s[0] = std::toupper(s[0]);
    } else {
      s[0] = std::tolower(s[0]);
    }
    std::cout << s;
    return 0;
  } else {
    if (std::islower(s[0])) {
      for (int i = 1; i != s.size(); i++) {
        if (islower(s[i])) {
          std::cout << s;
          return 0;
        }
      }
      s[0] = std::toupper(s[0]);
      for (int i = 1; i != s.size(); i++) {
        s[i] = std::tolower(s[i]);
      }
      std::cout << s;
      return 0;
    } else {
      for (int i = 1; i != s.size(); i++) {
        if (std::islower(s[i])) {
          std::cout << s;
          return 0;
        }
      }
      s[0] = std::tolower(s[0]);
      for (int i = 1; i != s.size(); i++) {
        s[i] = std::tolower(s[i]);
      }
      std::cout << s;
      return 0;
    }
  }
}
