#include <bits/stdc++.h>
using namespace std;
string cap(string s) {
  string re;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] >= 97) {
      re += s[i] - 32;
    } else {
      re += s[i] + 32;
    }
  }
  return re;
}
int main() {
  string s;
  cin >> s;
  bool b = 0;
  int o = 0;
  char c = s[0];
  if (c >= 97) {
    o = 1;
  }
  for (int i = o; i < s.length(); i++) {
    char c = s[i];
    if (c >= 97) {
      b = 1;
    }
  }
  if (b) {
    cout << s;
  } else {
    cout << cap(s);
  }
  return 0;
}
