#include <bits/stdc++.h>
using namespace std;
int main() {
  char ar[100];
  int len, count = 0, i, j;
  gets(ar);
  len = strlen(ar);
  if (isupper(ar[0]) && islower(ar[1])) {
    cout << ar;
  } else {
    for (i = 0; ar[i] != '\0'; i++) {
      if (isupper(ar[i])) {
        count++;
      }
    }
    if (len == 1) {
      if (islower(ar[0])) {
        ar[0] = toupper(ar[0]);
      } else if (isupper(ar[0])) {
        ar[0] = tolower(ar[0]);
      }
    } else if (count == len) {
      for (i = 0; ar[i] != '\0'; i++) {
        ar[i] = tolower(ar[i]);
      }
    } else if (count == len - 1) {
      if (islower(ar[0])) {
        for (i = 1; ar[i] != '\0'; i++) {
          ar[i] = tolower(ar[i]);
          ar[0] = toupper(ar[0]);
        }
      }
    }
    cout << ar;
  }
  return 0;
}
