public static void main(String[] args) throws Throwable{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		boolean may=false;
		StringBuilder sb=new StringBuilder();
		for(String ln;(ln=in.readLine())!=null;){
			if(ln.equals(""))may=false;
			char[] str=ln.toCharArray();
			for(int i=0;i<str.length;i++){
				if(str[i]=='.'||str[i]=='?'||str[i]=='!')may=true;
				if(Character.isDigit(str[i]))may=false;
				if(Character.isLetter(str[i])){
					if(may)sb.append(Character.toUpperCase(str[i]));
					else sb.append(Character.toLowerCase(str[i]));
					may=false;
				}
				else sb.append(str[i]);
			}
			sb.append("\n");
		}
		System.out.print(new String(sb));
	}