program Project2; {$APPTYPE CONSOLE} uses SysUtils; var z,big,small:set of char; i,j:integer; b,t,x,k,q:boolean; a:array[0..501]of char; procedure invers(a:char); begin if a in big then write(chr(ord(a)+32))else write(chr(ord(a)-32)) end; begin assign(input,'text.in'); reset(input); assign(output,'text.out'); rewrite(output); i:=0; z:=z+['.']+['?']+['!']; big:=big+['A'..'Z']; small:=small+['a'..'z']; b:=false; t:=false; while not eoln do begin inc(i); read(a[i]); end; x:=true; q:=false; for j:=1 to i do begin if not(b)then begin if (a[j]in small)and(a[j+1]in big)then begin b:=true; k:=true; end else if((a[j]in big)and((a[j+1])in big))then begin t:=true; b:=true end; end; if (b)and(not(q))then begin q:=true; if ((x)and(k))or(not(x)and(t)) then invers(a[j]) else write(a[j]); end else if (a[j]in big)or(a[j]in small)then invers(a[j])else write(a[j]); if a[j]in z then x:=true else x:=false; end; close(input); writeln; close(output); end.