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