#include <bits/stdc++.h>
using namespace std;
ifstream in("test.in");
ofstream out("r10.out");
int main() {
  string s;
  cin >> s;
  bool ver = 1;
  for (int i = 1; i < s.size(); i++) {
    if (!isupper(s[i])) {
      ver = 0;
      break;
    }
  }
  if (ver == 0)
    cout << s;
  else {
    for (int i = 0; i < s.size(); i++) {
      if (isupper(s[i]))
        cout << char(tolower(s[i]));
      else
        cout << char(toupper(s[i]));
    }
  }
}
