#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int n = s.size();
  bool flag = 1;
  for (int i = 1; i < n; i++)
    if (!(s[i] >= 'A' && s[i] <= 'Z')) flag = 0;
  if (flag) {
    for (int i = 0; i < n; i++)
      if ('a' <= s[i] && s[i] <= 'z')
        cout << (char)(s[i] + 'A' - 'a');
      else
        cout << (char)(s[i] + 'a' - 'A');
    cout << endl;
  } else
    cout << s << endl;
  return 0;
}
