#include <bits/stdc++.h>
int isUpper(char *arr) {
  int i;
  char c;
  c = arr[0];
  for (i = 1; c != '\0'; i++) {
    if (c >= 'a' && c <= 'z') return 0;
    c = arr[i];
  }
  return 1;
}
void printToggle(char *arr) {
  int i;
  char c;
  i = 0;
  c = arr[0];
  while (c != '\0') {
    if (c >= 'a' && c <= 'z') {
      printf("%c", c - 32);
    } else if (c >= 'A' && c <= 'Z') {
      printf("%c", c + 32);
    }
    i++;
    c = arr[i];
  }
  printf("\n");
}
int main() {
  char str[100 + 10];
  int caps;
  scanf("%s", str);
  caps = 1;
  if (str[0] >= 'a' && str[0] <= 'z') {
    caps = isUpper(&str[1]);
  } else {
    caps = isUpper(&str[1]);
  }
  if (caps == 1) {
    printToggle(str);
  } else {
    printf("%s\n", str);
  }
}
