#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100], c = 0;
  cin >> s;
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') c++;
  }
  if (strlen(s) == 1) {
    if (s[0] >= 'a' && s[0] <= 'z')
      s[0] = s[0] - 32;
    else
      s[0] = s[0] + 32;
  }
  if (c == 1) {
    if (s[0] >= 'a' && s[0] <= 'z' && s[1] >= 'A' && s[1] <= 'Z') {
      s[0] = s[0] - 32;
      for (int i = 1; i < strlen(s); i++) {
        s[i] = s[i] + 32;
      }
    }
  } else if (s[0] >= 'A' && s[0] <= 'Z' && s[1] >= 'A' && s[1] <= 'Z' &&
             c == 0) {
    for (int i = 0; i < strlen(s); i++) {
      s[i] = s[i] + 32;
    }
  }
  cout << s;
}
