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