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