#include <bits/stdc++.h>
using namespace std;
bool mayus(string s) {
  for (int i = 0; i < s.size(); i++)
    if (toupper(s[i]) != s[i]) return false;
  return true;
}
bool mayus2(string s) {
  for (int i = 1; i < s.size(); i++)
    if (toupper(s[i]) != s[i]) return false;
  return true;
}
int main() {
  string s;
  getline(cin, s);
  if (s.size() == 0) {
    if (tolower(s[0]) == s[0])
      printf("%c\n", toupper(s[0]));
    else
      printf("%c\n", s[0]);
  } else if (mayus(s)) {
    for (int i = 0; i < s.size(); i++) printf("%c", tolower(s[i]));
    printf("\n");
  } else if (mayus2(s)) {
    printf("%c", toupper(s[0]));
    for (int i = 1; i < s.size(); i++) printf("%c", tolower(s[i]));
    printf("\n");
  } else
    cout << s << endl;
}
