#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  getline(cin, str);
  int l = str.size();
  int cnt = 0;
  for (int i = 0; i < l; i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') {
      cnt++;
    }
  }
  if (cnt == l || (cnt == l - 1 && (str[0] >= 'a' && str[0] <= 'z'))) {
    if (str[0] >= 'a' && str[0] <= 'z') {
      str[0] = str[0] - 'a' + 'A';
    }
    int k = 0;
    if (cnt == l - 1) {
      k = 1;
    }
    for (int i = k; i < l; i++) {
      str[i] = str[i] - 'A' + 'a';
    }
  }
  cout << str << endl;
  return 0;
}
