1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <iostream>
4 #include <string.h>
5 #include <limits.h>
6 #include <queue>
7 #include <vector>
8 #include <set>
9 #include <map>
10 #include <algorithm>
11
12 using namespace std;
13
14
15 char buf[10000];
16
17 bool iszimu(char c) {
18 return ((c>='a' && c<='z') || (c>='A' && c<='Z'));
19 }
20 char turn_capital(char c) {
21 if (c>='a' && c<='z') {
22 c = c + 'A' - 'a';
23 }
24 return c;
25 }
26 char turn_small(char c) {
27 if (c>='A' && c<='Z') c = c+'a'-'A';
28 return c;
29 }
30 int main()
31 {
32 while(scanf("%[^\n]", buf)>0){
33 //printf("%s\n", buf);
34 char str[10000] = {0};
35 int j = 0;
36 for (int i=0;buf[i]!=0;++i) {
37 if (iszimu(buf[i])) {
38 if (j==0 || str[j-2] == '.') {
39 str[j] = turn_capital(buf[i]);
40 } else {
41 str[j] = turn_small(buf[i]);
42 }
43 } else if (buf[i] == ' ') {
44 if (j==0) continue;
45 if (str[j-1] != ' ') str[j] = buf[i];
46 else j--;
47 } else if (buf[i] == ',' || buf[i] == '.') {
48 if (str[j-1] == ' ') {
49 str[j-1] = buf[i];
50 str[j] = ' ';
51 } else {
52 str[j] = buf[i];
53 str[j+1] = ' ';
54 j++;
55 }
56 }
57 j++;
58 }
59 printf("%s\n", str);
60 getchar();
61 }
62 }