#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[10000];
  cin >> s;
  int uc = 0, n = strlen(s);
  for (int i = 0; i < n; i++) {
    if (s[i] < 'a') {
      uc++;
    }
  }
  if (s[0] >= 'a' && uc == n - 1) {
    if (s[0] >= 'a') {
      s[0] = s[0] - 32;
    }
    for (int i = 1; s[i] != '\0'; i++) {
      if (s[i] < 'a') {
        s[i] = s[i] + 32;
      }
    }
  }
  if (uc == n) {
    for (int i = 0; s[i] != '\0'; i++) {
      s[i] = s[i] + 32;
    }
  }
  cout << s;
}
