#include <bits/stdc++.h>
using namespace std;
int a, c, n, m;
string s;
int main() {
  string s;
  cin >> s;
  int d = 0;
  for (int i = 0; i < s.size(); i++)
    if (i > 0 && islower(s[i])) d = 1;
  if (d == 1) {
    cout << s;
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    if (isupper(s[i]))
      cout << (char)tolower(s[i]);
    else
      cout << (char)toupper(s[i]);
  }
}
