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