#include <bits/stdc++.h>
int main() {
  int i;
  int j, flag = 1;
  char Str[100];
  scanf("%s", Str);
  for (i = 1; Str[i] != '\0'; i++) {
    if (Str[i] >= 97 && Str[i] <= 122) {
      flag = 0;
      break;
    }
  }
  if (flag == 1) {
    if (Str[0] >= 65 && Str[0] <= 90)
      Str[0] = Str[0] + 32;
    else
      Str[0] = Str[0] - 32;
    for (j = 1; Str[j] != '\0'; j++) {
      Str[j] = Str[j] + 32;
    }
  }
  printf("%s\n", Str);
  return 0;
}
