#include <bits/stdc++.h>
using ::std::cin;
using ::std::cout;
using ::std::string;
bool malaLiterka(string s) {
  return s.length() == 1 && s[0] >= 'a' && s[0] <= 'z';
}
bool duzeLiterki(string s) {
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] >= 'a' && s[i] <= 'z') return false;
  }
  return true;
}
bool malaDuza(string s) {
  if (s[0] >= 'a' && s[0] <= 'z') {
    for (int i = 1; i < s.length(); ++i) {
      if (s[i] >= 'a' && s[i] <= 'z') return false;
    }
    return true;
  }
  return false;
}
int main() {
  string s;
  cin >> s;
  if (malaLiterka(s))
    s[0] -= 'a' - 'A';
  else if (duzeLiterki(s)) {
    for (int i = 0; i < s.length(); ++i) {
      s[i] += 'a' - 'A';
    }
  } else if (malaDuza(s)) {
    s[0] -= 'a' - 'A';
    for (int i = 1; i < s.length(); ++i) {
      s[i] += 'a' - 'A';
    }
  }
  cout << s;
  return 0;
}
