#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, f = 0, t = 0, mini;
  string s1, s2;
  cin >> s1;
  for (i = 1; i < s1.length(); i++) {
    if (s1[i] < 92 && s1[i] > 64) f++;
  }
  if (f == s1.length() - 1) {
    if (s1[0] < 92)
      cout << (char)tolower(s1[0]);
    else
      cout << (char)toupper(s1[0]);
    for (i = 1; i < s1.length(); i++) {
      cout << (char)tolower(s1[i]);
    }
  } else
    cout << s1;
  return 0;
}
