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