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