#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool ch = true;
  for (int i = 1; i < s.size(); i++) {
    if (toupper(s[i]) != s[i]) {
      ch = false;
      break;
    }
  }
  if (ch) {
    for (int i = 1; i < s.size(); i++) {
      s[i] = tolower(s[i]);
    }
    if (s[0] == toupper(s[0]))
      s[0] = tolower(s[0]);
    else
      s[0] = toupper(s[0]);
  }
  cout << s << endl;
  return 0;
}
