#include <bits/stdc++.h>
using namespace std;
bool allb;
char pk[101];
int main() {
  while (~scanf("%s", &pk)) {
    bool sc = false;
    if (strlen(pk) == 1)
      printf("%c\n",
             pk[0] >= 'a' && pk[0] <= 'z' ? pk[0] - 0x20 : pk[0] + 0x20);
    else {
      for (int i = 1; i < strlen(pk); ++i) {
        if (pk[i] >= 'A' && pk[i] <= 'Z')
          sc = true;
        else {
          sc = false;
          break;
        }
      }
      if (sc) {
        if (pk[0] >= 'a' && pk[0] <= 'z')
          pk[0] -= 0x20;
        else
          pk[0] += 0x20;
        for (int i = 1; i < strlen(pk); ++i) {
          if (pk[i] >= 'A' && pk[i] <= 'Z') pk[i] += 0x20;
        }
      }
      printf("%s\n", pk);
    }
  }
  return 0;
}
