#include <bits/stdc++.h>
using namespace std;
int main() {
  string word, up = "";
  bool cond = true;
  cin >> word;
  for (int i = 0, l = word.length(); i < l; i++) {
    if (i == 0) {
      if (isupper(word[i]))
        up += tolower(word[i]);
      else
        up += toupper(word[i]);
    } else {
      if (isupper(word[i]))
        up += tolower(word[i]);
      else {
        cond = false;
        break;
      }
    }
  }
  if (!cond)
    cout << word;
  else
    cout << up;
  return 0;
}
