#include <bits/stdc++.h>
using namespace std;
int main() {
  string chipi;
  cin >> chipi;
  if (chipi[0] >= 'a') {
    bool r = true;
    for (int i = 1; i < chipi.size(); i++)
      if (chipi[i] >= 'a') r = false;
    if (r) {
      chipi[0] -= 32;
      for (int i = 1; i < chipi.size(); i++)
        if (chipi[i] < 'a') chipi[i] += 32;
    }
  } else {
    bool kk = true;
    for (int i = 1; i < chipi.size(); i++)
      if (chipi[i] >= 'a') kk = false;
    if (kk) {
      for (int i = 0; i < chipi.size(); i++)
        if (chipi[i] < 'a') chipi[i] += 32;
    }
  }
  cout << chipi;
  return 0;
}
