#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int flag = 0;
  int count = 0;
  if (isupper(s[0])) {
    flag = 1;
    count = 1;
  }
  for (int i = 1; i < s.length(); i++) {
    if (isupper(s[i])) count++;
  }
  if (count == s.length()) {
    for (int i = 0; i < s.length(); i++) {
      s[i] = tolower(s[i]);
    }
  } else if (count == s.length() - 1 && flag == 0) {
    s[0] = toupper(s[0]);
    for (int i = 1; i < s.length(); i++) {
      s[i] = tolower(s[i]);
    }
  }
  cout << s;
}
