#include <bits/stdc++.h>
using namespace std;
int main() {
  bool is = true;
  string s;
  cin >> s;
  if (isupper(s[0])) {
    for (int i = 1; i < s.length(); i++) {
      if (islower(s[i])) {
        is = false;
        break;
      }
    }
  } else {
    for (int i = 1; i < s.length(); i++) {
      if (islower(s[i])) {
        is = false;
        break;
      }
    }
  }
  if (is == true)
    for (int i = 0; i < s.length(); i++) {
      if (isupper(s[i]))
        s[i] += 32;
      else
        s[i] -= 32;
    }
  {}
  cout << s;
  return 0;
}
