#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cont = 1;
  if (s.size() > 1) {
    for (int i = 1; i < s.size(); i++) {
      if (isupper(s[i])) {
        cont++;
      } else
        continue;
    }
    if (cont == s.size()) {
      if (islower(s[0])) {
        s[0] = toupper(s[0]);
        for (int i = 1; i < s.size(); i++) s[i] = tolower(s[i]);
        cout << s;
      } else {
        s[0] = tolower(s[0]);
        for (int i = 1; i < s.size(); i++) s[i] = tolower(s[i]);
        cout << s;
      }
    } else
      cout << s;
  } else {
    (islower(s[0]) ? s[0] = toupper(s[0]) : s[0] = tolower(s[0]));
    cout << s;
  }
  return 0;
}
