#include <bits/stdc++.h>
int main() {
  char w[101];
  int i, len, flag = 0, flag1 = 0;
  scanf("%s", w);
  len = strlen(w);
  if (islower(w[0])) flag1 = 1;
  for (i = 1; i < len; i++)
    if (islower(w[i])) {
      flag++;
      flag1 = 1;
    }
  if (flag == 0 && flag1 == 1) {
    if (islower(w[0])) w[0] = toupper(w[0]);
    for (i = 1; i < len; i++) {
      if (isupper(w[i])) w[i] = tolower(w[i]);
    }
  }
  if (flag1 == 0)
    for (i = 0; i < len; i++) w[i] = tolower(w[i]);
  printf("%s\n", w);
  return 0;
}
