#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  char str[101];
  bool flag = true;
  cin >> str;
  for (int i = 1; str[i] != '\0'; i++) {
    if (islower(str[i])) {
      flag = false;
    }
  }
  if (flag) {
    for (int i = 0; str[i] != '\0'; i++) {
      if (islower(str[i])) {
        str[i] = toupper(str[i]);
      } else {
        str[i] = tolower(str[i]);
      }
    }
  }
  cout << str;
  return (0);
}
