#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  string s;
  cin >> s;
  long long int f = 0;
  for (long long int i = 1; i < s.length(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      f = 1;
      break;
    }
  }
  if (f == 0) {
    if (islower(s[0]))
      s[0] = toupper(s[0]);
    else
      s[0] = tolower(s[0]);
    for (long long int i = 1; i < s.length(); i++) {
      s[i] = tolower(s[i]);
    }
  }
  cout << s << endl;
  return 0;
}
