#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int penuh = 1;
  for (int i = 0; i < s.length(); i++) {
    if (i == 0) {
    } else {
      if (s[i] >= 'A' && s[i] <= 'Z') {
      } else
        penuh = 0;
    }
  }
  if (penuh == 1) {
    for (int i = 0; i < s.length(); i++) {
      if (s[i] >= 'a' && s[i] <= 'z')
        cout << (char)(s[i] - 32);
      else
        cout << (char)(s[i] + 32);
    }
    cout << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}
