https://codeforces.com/problemset/problem/131/A
#include<bits/stdc++.h>
using namespace std;
int cnt;
int main(void)
{
string s; cin>>s;
for(int i=0;i<s.size();i++) if(s[i]<='Z') cnt++;
if(cnt==s.size()||( (cnt==s.size()-1) && (s[0]>='a') ) )
{
for(int i=0;i<s.size();i++)
{
if(s[i]>='a') s[i]=toupper(s[i]);
else s[i]=tolower(s[i]);
}
}
cout<<s<<endl;
return 0;
}