#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void reverse(char *left, char *right)
{
    while(left < right)
    {
        char tmp = *left;
        *left = *right;
        *right = tmp;
        left++;
        right--;
    }
}
int main()
{
    char *p = (char*)malloc(10000);
    gets(p);
    int len = strlen(p);
    reverse(p, p+len-1);
    int j=0;
    for(int i=0; i<=len; i++)
    {
        if(!isalpha(p[i]))
        {
            p[i] = ' ';
            reverse(p+j, p+i-1);
            j = i+1;
        }
    }
    int cnt = 0;
    for(int i=0; i<len; i++)
    {
        if(p[i] == ' ' && p[i+1] == ' ')
        {
            int m = i+1;
            int n = i+2;
            p[m++] = p[n++];
            cnt++;
        }
    }
    for(int i=0; i<len-cnt;i++)
    {
        printf("%c", p[i]);
    }
    free(p);
    p = NULL;
}