#include <bits/stdc++.h>
int main() {
  char str[102];
  while (scanf("%s", str) != EOF) {
    char str1[102];
    getchar();
    int i, len = strlen(str), flag = 0;
    for (i = 1; i < len; i++) {
      if (str[i] >= 'A' && str[i] <= 'Z') {
        flag = 1;
        str1[i] = str[i] + 32;
      } else {
        flag = 0;
        break;
      }
    }
    if (len == 1) flag = 1;
    str1[len] = '\0';
    if (flag) {
      if (str[0] >= 'A' && str[0] <= 'Z')
        str1[0] = str[0] + 32;
      else
        str1[0] = str[0] - 32;
      puts(str1);
    } else
      puts(str);
  }
  return 0;
}
