#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string t = s;
  bool b = true;
  if ((int)t[0] >= 97 && (int)t[0] <= 122) {
    t[0] -= 32;
    for (int i = 1; i < t.size(); i++) {
      if ((int)t[i] >= 65 && (int)t[i] <= 90)
        t[i] += 32;
      else {
        b = false;
        break;
      }
    }
    if (b == true)
      cout << t;
    else
      cout << s;
  } else if ((int)t[0] >= 65 && (int)t[0] <= 90) {
    for (int i = 0; i < t.size(); i++) {
      if ((int)t[i] >= 65 && (int)t[i] <= 90)
        t[i] += 32;
      else {
        b = false;
        break;
      }
    }
    if (b == true)
      cout << t;
    else
      cout << s;
  } else
    cout << s;
  return 0;
}
