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