#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, k;
  int z = 0;
  getline(cin, s);
  k = s;
  for (int i = 1; i < s.length(); ++i) {
    if (int(s[i]) < 97) {
      s[i] = int(s[i]) + 32;
    } else if (i != 0) {
      z = 1;
      cout << k;
      break;
    }
  }
  if (z != 1) {
    if (int(s[0]) > 97 || int(s[0]) == 97) {
      s[0] = int(s[0]) - 32;
    } else
      s[0] = int(s[0]) + 32;
    cout << s;
  }
  return 0;
}
