#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  int count = 0, c = 0;
  cin >> a;
  count = a.size();
  for (int i = 0; a[i] != '\0'; i++) {
    if (a[i] >= 'A' && a[i] <= 'Z') c++;
  }
  if ((c == count) || ((c == count - 1) && (a[0] >= 'a' && a[0] <= 'z'))) {
    for (int i = 0; a[i] != '\0'; i++) {
      if (a[i] >= 'A' && a[i] <= 'Z')
        a[i] = a[i] + 32;
      else
        a[i] = a[i] - 32;
    }
  }
  for (int i = 0; a[i] != '\0'; i++) {
    cout << a[i];
  }
}
