#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[101];
  scanf("%s", s);
  int len = strlen(s);
  int upch = 0;
  for (int i = 0; i < len; ++i) {
    if (isupper(s[i])) ++upch;
  }
  bool flag = false;
  if (upch == len)
    flag = true;
  else if (islower(s[0]) && len - upch == 1)
    flag = true;
  if (flag) {
    for (int i = 0; i < len; ++i) {
      if (isupper(s[i]))
        putchar(s[i] + 32);
      else
        putchar(s[i] - 32);
    }
  } else {
    puts(s);
  }
  return 0;
}
