#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, c = 0;
  string st;
  cin >> st;
  n = st.length();
  for (i = 1; i < n; i++) {
    if (isupper(st[i])) c++;
  }
  if (c == n - 1) {
    if (islower(st[0]))
      st[0] = char(toupper(st[0]));
    else
      st[0] = char(tolower(st[0]));
    for (i = 1; i < n; i++) st[i] = char(tolower(st[i]));
  }
  cout << st;
  return 0;
}
