#include <bits/stdc++.h>
using namespace std;
int main() {
  string in;
  cin >> in;
  if (in.size() == 1)
    if (islower(in[0]))
      printf("%c", toupper(in[0]));
    else
      printf("%c", tolower(in[0]));
  else {
    bool all_caps = true;
    for (int i = 1; in[i] != '\0'; i++) {
      if (islower(in[i])) all_caps = false;
    }
    if (all_caps && !islower(in[0])) {
      for (int i = 0; in[i] != '\0'; i++) printf("%c", tolower(in[i]));
    } else if (all_caps && islower(in[0])) {
      printf("%c", toupper(in[0]));
      for (int i = 1; in[i] != '\0'; i++) printf("%c", tolower(in[i]));
    } else
      cout << in;
  }
  printf("\n");
  return 0;
}
