#include <bits/stdc++.h>
using namespace std;
bitset<1000001> primeArr;
void sieve() {
  int num_sqrt = sqrt(1000000);
  primeArr[1] = 1;
  for (int i = 4; i <= 1000000; i += 2) primeArr[i] = 1;
  for (int i = 3; i <= num_sqrt; i += 2) {
    for (int j = 2; i * j <= 1000000; j++) primeArr[i * j] = 1;
  }
}
int main() {
  string s, c;
  cin >> s;
  c = s;
  bool check = true;
  if (s[0] > 90) {
    for (int i = 1; i < s.size(); i++) {
      if (s[i] <= 90)
        s[i] += 32;
      else {
        check = false;
        break;
      }
    }
    if (check) s[0] -= 32;
  } else {
    for (int i = 1; i < s.size(); i++) {
      if (s[i] <= 90)
        s[i] += 32;
      else {
        check = false;
        break;
      }
    }
    if (check) s[0] += 32;
  }
  if (check) {
    cout << s << endl;
  } else
    cout << c << endl;
  return 0;
}
