#include <bits/stdc++.h>
int main() {
  char s[110];
  scanf("%s", s);
  int len = strlen(s);
  if (len == 1) {
    if (s[0] >= 'A' && s[0] <= 'Z')
      s[0] = tolower(s[0]);
    else
      s[0] = toupper(s[0]);
    puts(s);
    return 0;
  }
  int acnt = 0, bcnt = 0;
  if (s[0] >= 'A' && s[0] <= 'Z') acnt++;
  for (int i = 1; i < len; i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') acnt++, bcnt++;
  }
  if (acnt == len) {
    for (int i = 0; i < len; i++) s[i] = tolower(s[i]);
  } else if (bcnt == len - 1) {
    s[0] = toupper(s[0]);
    for (int i = 1; i < len; i++) s[i] = tolower(s[i]);
  }
  puts(s);
}
