#include <bits/stdc++.h>
using namespace std;
int main() {
  int q = 0;
  char s[100];
  scanf("%s", s);
  for (int i = 1; i < strlen(s); i++) {
    if (s[i] >= 65 && s[i] <= 90) {
      q++;
    }
  }
  if (q == strlen(s) - 1) {
    for (int i = 0; i < strlen(s); i++) {
      if (s[i] >= 65 && s[i] <= 90)
        s[i] = 97 + s[i] - 65;
      else if (s[i] >= 97 && s[i] <= 122)
        s[i] = 65 + s[i] - 97;
    }
  }
  printf("%s\n", s);
  return 0;
}
