#include <bits/stdc++.h>
using namespace std;
void show(string s) {
  char c;
  c = toupper(s[0]);
  cout << c;
  for (int i = 1; i < s.length(); i++) {
    c = tolower(s[i]);
    cout << c;
  }
}
void show2(string s) {
  char c;
  for (int i = 0; i < s.length(); i++) {
    c = tolower(s[i]);
    cout << c;
  }
}
int main() {
  string s;
  cin >> s;
  int len = s.length();
  char c;
  if (s.length() == 1) {
    if (s[0] >= 'a' && s[0] <= 'z')
      c = toupper(s[0]);
    else
      c = tolower(s[0]);
    cout << c;
    return 0;
  }
  int u = 0, l = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] >= 'a' && s[i] <= 'z')
      l++;
    else
      u++;
  }
  if (l == 0) {
    show2(s);
    return 0;
  }
  if ((s[0] >= 'a' && s[0] <= 'z') && l == 1) {
    show(s);
    return 0;
  }
  cout << s;
  return 0;
}
