#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int i, c = 0, a = 0;
  for (i = 0; i < s.length(); i++) {
    if (s[0] >= 97 && s[0] <= 122) a = 1;
    if (s[i] >= 65 && s[i] <= 90) c++;
  }
  if (!((c == i) || ((c + a) == i)))
    cout << s;
  else {
    for (int j = 0; j < s.length(); j++) {
      if (s[j] >= 97) {
        s[j] -= 32;
      } else
        s[j] += 32;
      cout << s[j];
    }
  }
  return 0;
}
