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