#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.length();
  bool p = false, q = false;
  for (int i = 0; i < l; i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      p = true;
      break;
    }
  }
  if (s[0] >= 'a' && s[0] <= 'z') {
    q = true;
  }
  bool z = false;
  if (q == true) {
    for (int i = 1; i < l; i++) {
      if (s[i] >= 'a' && s[i] <= 'z') {
        z = true;
        break;
      }
    }
  }
  if (p == false || q == true && z == false) {
    for (int i = 0; i < l; i++) {
      if (s[i] >= 'A' && s[i] <= 'Z')
        s[i] = s[i] + 32;
      else
        s[i] = s[i] - 32;
    }
    cout << s;
  } else
    cout << s;
}
