#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long double EPS = 1e-10;
const int MAX = 1000 * 1000;
const int MOD = 1000;
int main() {
  string s, gl = "aoyeui", ans = "";
  cin >> s;
  int n = int(s.length());
  bool is_caps = true;
  for (int i = 1; i < n; i++) {
    if ('A' > s[i] || s[i] > 'Z') {
      is_caps = false;
      break;
    }
  }
  if (is_caps) {
    for (int i = 0; i < n; i++) {
      s[i] >= 'a' ? s[i] = char(int(s[i]) - 32) : s[i] = char(int(s[i]) + 32);
    }
  }
  cout << s;
}
