#include <bits/stdc++.h>
using namespace std;
bool isCaps(string str) {
  for (int i = 1; i < str.length(); ++i) {
    if (!isupper(str[i])) {
      return false;
    }
  }
  return true;
}
int main() {
  string word;
  cin >> word;
  if (isCaps(word)) {
    if (isupper(word[0])) {
      cout << (char)tolower(word[0]);
    } else {
      cout << (char)toupper(word[0]);
    }
    for (int i = 1; i < word.length(); ++i) {
      cout << (char)tolower(word[i]);
    }
  } else {
    cout << word;
  }
}
