#include <bits/stdc++.h>
using namespace std;
int main() {
  string w;
  cin >> w;
  bool ch = 1;
  for (int i = 1; i < w.size(); i++) {
    if (w[i] > 92 && ch) {
      ch = !ch;
      break;
    }
  }
  if (ch) {
    for (int i = 0; i < w.size(); i++) {
      if (w[i] > 92)
        w[i] = (char)(w[i] - 32);
      else
        w[i] = (char)(w[i] + 32);
    }
    cout << w << endl;
  } else
    cout << w << endl;
  return 0;
}
