#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
const long long MOD = 1000000007;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  string s;
  cin >> s;
  int i, c = 0, len;
  len = ((int)(s).size());
  for (i = 1; i < len; i++) {
    if (s[i] >= 65 && s[i] <= 90) c++;
  }
  if (c == len - 1) {
    s[0] >= 97 ? s[0] -= 32 : s[0] += 32;
    for (i = 1; i < len; i++) {
      if (s[i] >= 65 && s[i] <= 90) {
        s[i] += 32;
      }
    }
  }
  cout << s << "\n";
  return 0;
}
