#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool b = true;
  bool a = true;
  if (s[0] > 96) {
    for (int i = 1; i < s.size(); i++) {
      if (s[i] > 96) {
        b = false;
      }
    }
    if (b) {
      s[0] = s[0] - 32;
      for (int i = 1; i < s.size(); i++) {
        s[i] = s[i] + 32;
      }
    }
  } else {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] > 96) {
        a = false;
      }
    }
    if (a) {
      for (int i = 0; i < s.size(); i++) {
        s[i] = s[i] + 32;
      }
    }
  }
  cout << s;
}
