#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int x = 0;
  cin >> s;
  for (int i = 1; i < s.length(); i++) {
    if (isupper(s[i])) x++;
  }
  if (x == s.length() - 1) {
    for (int i = 0; i < s.length(); i++) {
      if (isupper(s[i])) {
        s[i] = tolower(s[i]);
      } else {
        s[i] = toupper(s[i]);
      }
    }
  }
  cout << s;
  return 0;
}
