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