#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int cnt = 0, cnt2 = 0;
  cin >> s;
  if (s.size() == 1) {
    if (isupper(s[0])) {
      putchar(tolower(s[0]));
    } else
      putchar(toupper(s[0]));
    return 0;
  }
  if (islower(s[0]) && s.size() > 1) {
    for (int i = 1; i < s.size(); i++) {
      if (isupper(s[i])) {
        cnt++;
      }
    }
  }
  if (cnt == s.size() - 1 && s.size() > 1) {
    putchar(toupper(s[0]));
    for (int i = 1; i < s.size(); i++) {
      putchar(tolower(s[i]));
    }
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    if (isupper(s[i])) {
      cnt2++;
    }
  }
  if (cnt2 == s.size()) {
    for (int i = 0; i < s.size(); i++) {
      putchar(tolower(s[i]));
    }
    return 0;
  }
  cout << s;
  return 0;
}
