#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  string str;
  cin >> str;
  int l = 0;
  for (int i = 1; i < str.length(); ++i) {
    if (isupper(str[i])) l++;
  }
  if (l == str.length() - 1) {
    for (int i = 1; i < str.length(); ++i) {
      str[i] = tolower(str[i]);
    }
    if (isupper(str[0]))
      str[0] = tolower(str[0]);
    else
      str[0] = toupper(str[0]);
  }
  cout << str;
  return 0;
}
