#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[101];
  int i, len;
  bool vis;
  while (cin >> c) {
    len = strlen(c);
    for (i = 1, vis = true; i < len; i++)
      if (c[i] >= 97) vis = false;
    if (vis) {
      if (c[0] >= 97)
        cout << char(c[0] - 32);
      else
        cout << char(c[0] + 32);
      for (i = 1; i < len; i++) {
        if (c[i] >= 97)
          cout << c[i];
        else
          cout << char(c[i] + 32);
      }
    } else
      cout << c;
    cout << endl;
  }
  return 0;
}
