#include <bits/stdc++.h>
using namespace std;
int t1, t2, n;
int main() {
  string a;
  cin >> a;
  n = a.size();
  for (int i = 0; i < n; i++) {
    if (!(a[i] >= 'A' && a[i] <= 'Z')) t1 = 1;
  }
  if (t1 == 0) {
    for (int i = 0; i < n; i++) {
      a[i] = 'a' + (a[i] - 'A');
    }
    cout << a;
  } else {
    if (!(a[0] >= 'a' && a[0] <= 'z')) t2 = 1;
    if (t2 == 0) {
      for (int i = 1; i < n; i++) {
        if (!(a[i] >= 'A' && a[i] <= 'Z')) t2 = 1;
      }
      if (t2 == 0) {
        a[0] = 'A' + (a[0] - 'a');
        for (int i = 1; i < n; i++) {
          a[i] = 'a' + (a[i] - 'A');
        }
        cout << a;
      } else
        cout << a;
    } else
      cout << a;
  }
}
