#include <bits/stdc++.h>
using namespace std;
bool checkAccident(string word) {
  bool allCaps = true;
  for (int i = 1; i < word.length(); i++) {
    if (word[i] >= 'A' && word[i] <= 'Z') {
    } else {
      allCaps = false;
      break;
    }
  }
  if (allCaps)
    return true;
  else
    return false;
}
int main() {
  string word;
  cin >> word;
  if (checkAccident(word)) {
    if (word[0] > 'Z') {
      cout << (char)(word[0] - 32);
    } else {
      cout << (char)(word[0] + 32);
    }
    for (int i = 1; i < word.length(); i++) {
      cout << (char)(word[i] + 32);
    }
  } else {
    cout << word;
  }
  return 0;
}
