#include <bits/stdc++.h>
int main() {
  char a[100];
  int len, sign1, sign2, i;
  gets(a);
  len = strlen(a);
  sign1 = 0;
  sign2 = 0;
  if (a[0] < 'A' || a[0] > 'Z') sign1++;
  for (i = 0; i < len; i++) {
    if (a[i] >= 'A' && a[i] <= 'Z') sign2++;
  }
  if (sign2 == len || sign2 == len - 1 && sign1 == 1) {
    for (i = 0; i < len; 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;
    }
  }
  for (i = 0; i < len; i++) printf("%c", a[i]);
  printf("\n");
  return 0;
}
