#include <bits/stdc++.h>
using namespace ::std;
int main() {
  char g[1000], i;
  cin >> g;
  int k = 0;
  if (g[0] >= 97 && g[0] <= 122) {
    for (i = 1; g[i] != '\0'; i++)
      if (g[i] >= 97 && g[i] <= 122) k = 1;
    if (k == 0) {
      for (i = 0; g[i] != '\0'; i++) {
        if (g[i] >= 97 && g[i] <= 122)
          g[i] = g[i] - 32;
        else if (g[i] >= 65 && g[i] <= 90)
          g[i] = g[i] + 32;
      }
    }
    cout << "\n" << g;
  } else if (g[0] >= 65 && g[0] <= 90) {
    int d = 0;
    for (i = 0; g[i] != '\0'; i++) {
      if (g[i] >= 97 && g[i] <= 122) d = 1;
    }
    if (d == 0)
      for (i = 0; g[i] != '\0'; i++) {
        if (g[i] >= 97 && g[i] <= 122)
          g[i] = g[i] - 32;
        else if (g[i] >= 65 && g[i] <= 90)
          g[i] = g[i] + 32;
      }
    cout << "\n" << g;
  } else
    cout << "\n" << g;
  return 0;
}
