#include <bits/stdc++.h>
using namespace std;
bool is_Capital(char& c) { return c >= 'A' && c <= 'Z'; }
void swap_case(string& s) {
  for (int i = 0; i < s.size(); i++) {
    if (is_Capital(s[i]))
      s[i] = tolower(s[i]);
    else
      s[i] = toupper(s[i]);
  }
}
void read() {
  int n;
  string s;
  bool caps = true;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (!is_Capital(s[i]) && i != 0) {
      caps = false;
    }
  }
  if (caps) swap_case(s);
  cout << s;
}
int main() {
  read();
  return 0;
}
