#include <bits/stdc++.h>
using namespace std;
string Convert(string s) {
  for (int i = 0; i < (int)s.length(); i++) {
    if (isupper(s[i]))
      s[i] = tolower(s[i]);
    else if (islower(s[i]))
      s[i] = toupper(s[i]);
  }
  return s;
}
int main() {
  string s;
  cin >> s;
  bool upper = false;
  for (int i = 1; i < (int)s.length(); i++) {
    if (isupper(s[i])) {
      upper = true;
    } else {
      upper = false;
      break;
    }
  }
  (upper || s.length() == 1) ? cout << Convert(s) : cout << s;
  return 0;
}
