#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1000];
  cin >> a;
  int n = strlen(a), i, up = 1;
  for (i = 1; i < n; i++)
    if (a[i] >= 'a' && a[i] <= 'z') up = 0;
  if (up) {
    for (i = 1; i < n; i++) a[i] = a[i] + 'a' - 'A';
    if (a[0] >= 'A' && a[0] <= 'Z')
      a[0] = a[0] + 'a' - 'A';
    else
      a[0] = a[0] + 'A' - 'a';
  }
  cout << a;
}
