#include <bits/stdc++.h>
const double PI = acos(-1.0);
const double e = exp(1.0);
const int INF = 0x7fffffff;
;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline T Min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T Max(T a, T b) {
  return a > b ? a : b;
}
bool cmpbig(int a, int b) { return a > b; }
bool cmpsmall(int a, int b) { return a < b; }
using namespace std;
int n, v[100010], pos[100010];
bool canmeet(double t) {
  double lmin = 1e9, rmax = -1;
  for (int i = 0; i < n; i++) {
    lmin = min(lmin, pos[i] + v[i] * t);
    rmax = max(rmax, pos[i] - v[i] * t);
  }
  if (lmin >= rmax) return true;
  return false;
}
bool upper(char c) {
  if (c >= 'A' && c <= 'Z') return true;
  return false;
}
bool lowper(char c) {
  if (c >= 'a' && c <= 'z') return true;
  return false;
}
void toupper(char &c) { c -= 32; }
void tolowper(char &c) { c += 32; }
int main() {
  char str[1010];
  while (~scanf("%s", str)) {
    int cnt = 0, l = strlen(str);
    for (int i = 0; i < l; i++) {
      if (lowper(str[i])) cnt++;
    }
    if (cnt == 0 || (cnt == 1 && lowper(str[0]))) {
      for (int i = 0; i < l; i++) {
        if (!upper(str[i]))
          toupper(str[i]);
        else
          tolowper(str[i]);
      }
    }
    cout << str << endl;
  }
  return 0;
}
