#include <bits/stdc++.h>
const int maxN = 200005;
using namespace std;
bool checkIsWrongTyping(string s) {
  for (int i = 1; i < s.length(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') return false;
  }
  return true;
}
int main() {
  int t = 1;
  while (t-- > 0) {
    string s;
    cin >> s;
    if (checkIsWrongTyping(s)) {
      for (int i = 0; i < s.length(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z') {
          s[i] = toupper(s[i]);
        } else {
          s[i] = tolower(s[i]);
        }
      }
    }
    cout << s;
  }
}
