#include <bits/stdc++.h>
using namespace std;
signed main() {
  string str;
  int i, countc = 0;
  cin >> str;
  for (i = 0; i < str.length(); i++) {
    if (int(str[i]) >= 65 && int(str[i]) < 97) {
      countc++;
    }
  }
  if (countc == str.length()) {
    for (i = 0; i < str.length(); i++) {
      if (int(str[i]) >= 97) {
        str[i] = char(int(str[i] - 32));
      } else {
        str[i] = char(int(str[i]) + 32);
      }
    }
  } else if (countc == str.length() - 1 && int(str[0]) >= 97) {
    for (i = 0; i < str.length(); i++) {
      if (int(str[i]) >= 97) {
        str[i] = char(int(str[i] - 32));
      } else {
        str[i] = char(int(str[i]) + 32);
      }
    }
  }
  cout << str;
}
