#include <bits/stdc++.h>
using namespace std;
void change(string &s) {
  for (int i = 0; i < s.length(); i++) {
    s[i] = (s[i] < 97) ? tolower(s[i]) : toupper(s[i]);
  }
}
int main() {
  string s;
  cin >> s;
  int len = s.length(), capCount = 0;
  bool Caps = false;
  for (int i = 0; i < len; i++) capCount += ((int)s[i] < 97);
  if (capCount == len || (capCount == len - 1 && s[0] >= 97)) change(s);
  cout << s << endl;
  return 0;
}
