#include <bits/stdc++.h>
using namespace std;
string s;
int gede;
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    if (s[i] >= 'A' && s[i] <= 'Z') gede++;
  if (gede == s.size()) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
    }
  }
  if (gede + 1 == s.size() and s[0] >= 'a' and s[0] <= 'z') {
    if (s[0] <= 'z' and s[0] >= 'a') s[0] = s[0] - 'a' + 'A';
    for (int i = 1; i < s.size(); i++)
      if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  }
  cout << s << endl;
}
