#include <bits/stdc++.h>
using namespace std;
int main() {
  string x, y, z;
  cin >> x;
  y += tolower(x[0]);
  z += toupper(x[0]);
  for (int i = 1; i < x.size(); i++) {
    y += toupper(x[i]);
    z += toupper(x[i]);
  }
  if (x == y || x == z || x.size() == 1) {
    for (int i = 0; i < x.size(); i++) {
      if (x[i] == toupper(x[i]))
        x[i] = tolower(x[i]);
      else
        x[i] = toupper(x[i]);
    }
  }
  cout << x << endl;
  return 0;
}
