#include <stdio.h>
#include <string.h>
int main() {
    char str[1000]={0};
    char temp[1000]={0};
    char space=' ';
    scanf("%[^\n]",str);
    int base=strlen(str)-1;
    // printf("%d",strlen(str));
    // printf("%d",base);
    for(int i=strlen(str)-1;i>=0;i--)
    {
        if ((str[i]==space)&&(i<base))
        {
            strncpy(temp,str+i+1,base-i);
            printf("%s",temp);
            base=i-1;
            printf("%c",space);
            memset(temp,0,sizeof(temp));
        }
        if (i==0)
        {
            strncpy(temp,str,base+1);
            printf("%s",temp);
        }
    }
}