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