#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 0;
  int len = s.size();
  bool small = false;
  for (int i = 0; i < len; i++) {
    if (s[i] < 'a') {
      count++;
    }
    if (s[0] >= 'a') {
      small = true;
    }
  }
  if (count == len || (count == len - 1 && small)) {
    for (int i = 0; i < len; i++) {
      if (i == 0 && count == len) {
        s[i] = s[i] + 32;
      } else if (i == 0 && small) {
        s[i] = s[i] - 32;
      } else {
        s[i] = s[i] + 32;
      }
    }
  }
  cout << s << endl;
}
