#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
  bool State = true;
  cin >> S;
  for (int i = 1; i < S.length(); i++) {
    if (S[i] >= 'a' && S[i] <= 'z') {
      State = false;
    }
  }
  if (State) {
    for (int i = 1; i < S.length(); i++) {
      S[i] = tolower(S[i]);
    }
    if (S[0] >= 'a' && S[0] <= 'z') {
      S[0] = toupper(S[0]);
    } else if (S[0] >= 'A' && S[0] <= 'Z') {
      S[0] = tolower(S[0]);
    }
  }
  cout << S;
  return 0;
}
