#include <bits/stdc++.h>
using namespace std;
int upper(string s) {
  for (int i = 0; s[i] != '\0'; i++) {
    if (isupper(s[i]) == 0) return 0;
  }
  return 1;
}
int func(string s) {
  if (islower(s[0]) == 0)
    return 0;
  else {
    for (int i = 1; s[i] != '\0'; i++) {
      if (isupper(s[i]) == 0) return 0;
    }
    return 1;
  }
}
int main() {
  string s;
  cin >> s;
  if (upper(s) == 1) {
    for (int i = 0; s[i] != '\0'; i++) cout << char(tolower(s[i]));
  } else if (func(s) == 1) {
    cout << char(toupper(s[0]));
    for (int i = 1; s[i] != '\0'; i++) cout << char(tolower(s[i]));
  } else
    cout << s << endl;
  return 0;
}
