#!/usr/bin/python3 import sys import re def upperToLower(m): temp='' if re.match(r'^([A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*[A-ZĄĆĘŁŃÓŚŹŻ]+[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*)|([A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻ]+[A-ZĄĆĘŁŃÓŚŹŻa-ząćęłńóśźż]*$)',m.group(0)): for l in m.group(0): if l.isupper(): temp+=l.lower() elif l.islower(): temp+=l.upper() else: temp+=l return str(temp) else: return str(m.group(0)) for line in sys.stdin.readlines(): temp=re.sub(r'\b\w+\b', upperToLower ,line) print(temp.strip('\n'))