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