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