#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[101];
  cin >> s;
  int i, capital = 0, small = 0, len = strlen(s);
  if (len == 1) {
    if (s[0] >= 'A' && s[0] <= 'Z')
      s[0] = s[0] + 32;
    else if (s[0] >= 'a' && s[0] <= 'z')
      s[0] = s[0] - 32;
    cout << s << endl;
  } else {
    if (s[0] >= 'a' && s[0] <= 'z') {
      i = 1;
      while (s[i] != '\0') {
        if (s[i] >= 'A' && s[i] <= 'Z')
          capital = 1;
        else
          small = 1;
        i++;
      }
      if (capital == 1 && small == 0) {
        i = 1;
        while (s[i] != '\0') {
          s[i] = s[i] + 32;
          i++;
        }
        s[0] = toupper(s[0]);
        cout << s << endl;
      } else if (capital == 1 && small == 1)
        cout << s << endl;
      else if (capital == 0 && small == 1)
        cout << s << endl;
    } else if (s[0] >= 'A' && s[0] <= 'Z') {
      i = 1;
      while (s[i] != '\0') {
        if (s[i] >= 'A' && s[i] <= 'Z')
          capital = 1;
        else
          small = 1;
        i++;
      }
      if (capital == 0 && small == 1) {
        cout << s << endl;
      } else if (capital == 1 && small == 1)
        cout << s << endl;
      else if (capital == 1 && small == 0) {
        i = 0;
        while (s[i] != '\0') {
          s[i] = s[i] + 32;
          i++;
        }
        cout << s << endl;
      }
    }
  }
}
