#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int i, k = 0, p = 0, l = 0;
  if (s[0] >= 97 && s[0] <= 122)
    p++;
  else
    k++;
  for (i = 1; i < s.size(); i++) {
    if (s[i] >= 97 && s[i] <= 122)
      l++;
    else
      k++;
  }
  if ((p == 1 && k == s.size() - 1)) {
    if (s[0] >= 97 && s[0] <= 122) s[0] = s[0] - 32;
    for (i = 1; i < s.size(); i++) {
      if (s[i] >= 64 && s[i] <= 91) s[i] = s[i] + 32;
    }
    cout << s << endl;
  } else if (k == s.size()) {
    for (i = 0; i < s.size(); i++) {
      if (s[i] >= 64 && s[i] <= 91) s[i] = s[i] + 32;
    }
    cout << s << endl;
  } else
    cout << s << endl;
  return 0;
}
