#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.length();
  bool con1 = true, con2 = true;
  for (int i = 0; i < l; i++) {
    if (s[i] > 90) {
      con1 = false;
      break;
    }
  }
  if (!con1) {
    if (s[0] < 90) {
      con2 = false;
    } else {
      con2 = true;
      for (int i = 1; i < l; i++) {
        if (s[i] > 90) {
          con2 = false;
          break;
        }
      }
    }
  }
  if (con1 || con2) {
    for (int i = 0; i < l; i++) {
      if (s[i] > 90) {
        s[i] -= 32;
      } else {
        s[i] += 32;
      }
    }
  }
  cout << s << endl;
  return 0;
}
