#include <bits/stdc++.h>
using namespace std;
int check(string s) {
  int b = 0;
  for (int i = 1; i < s.length(); i++) {
    if (isupper(s[i]))
      b++;
    else if (islower(s[i])) {
      b = 0;
    }
  }
  return b;
}
int main() {
  string s;
  cin >> s;
  if (s.length() == 1) {
    if (islower(s[0]))
      s[0] = toupper(s[0]);
    else if (isupper(s[0]))
      s[0] = tolower(s[0]);
    cout << s;
  }
  int k = check(s);
  int m = s.length();
  if ((k > 0) && (k == m - 1)) {
    for (int i = 1; i < s.length(); i++) {
      s[i] = tolower(s[i]);
    }
    if (islower(s[0]))
      s[0] = toupper(s[0]);
    else if (isupper(s[0]))
      s[0] = tolower(s[0]);
    cout << s;
  } else if (k != m - 1) {
    cout << s;
  }
  return 0;
}
