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