#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = 0, u = 0, n = s.size();
  for (auto c : s) {
    if (islower(c)) l++;
    if (isupper(c)) u++;
  }
  if (u == n || (islower(s[0]) && u == n - 1)) {
    for (auto &c : s) {
      if (islower(c))
        c = toupper(c);
      else
        c = tolower(c);
    }
  }
  cout << s;
  return 0;
}
