#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (getline(cin, s)) {
    int n = s.length();
    int count = 0;
    for (int i = 1; i < s.length(); i++) {
      if (s[i] >= 65 && s[i] <= 90) count++;
    }
    if (count != (n - 1))
      cout << s << endl;
    else {
      transform(s.begin() + 1, s.end(), s.begin() + 1, ::tolower);
      if (s[0] >= 65 && s[0] <= 90)
        s[0] = s[0] + 32;
      else if (s[0] >= 97 && s[0] <= 122)
        s[0] = s[0] - 32;
      cout << s << endl;
    }
  }
  return 0;
}
