#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void read(vector<int> &a) {
  for (auto &it : a) cin >> it;
}
void Solve() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      cnt++;
    }
  }
  if (cnt == s.size()) {
    for (int i = 0; i < s.size(); i++) {
      cout << (char)tolower(s[i]);
    }
    cout << "\n";
  } else if (cnt == (s.size() - 1) && s[0] >= 'a' && s[0] <= 'z') {
    cout << (char)toupper(s[0]);
    for (int i = 1; i < s.size(); i++) {
      cout << (char)tolower(s[i]);
    }
    cout << "\n";
  } else {
    cout << s << "\n";
  }
}
int32_t main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  Solve();
  return 0;
}
