#include <bits/stdc++.h>
using namespace std;

int main() {
    string line;
    getline(cin, line);

    vector<string> words;//字符串数组
    string word;

    for (char c : line) {
        if (isalpha(c)) {
            word.push_back(c);//将字母存进字符串
        } 
        else {
            if (!word.empty()) {
                words.push_back(word);//将字符串存进字符串数组
                word.clear();//清空当前字符串 存储下一个字符串
            }
        }
    }
    if (!word.empty()) {//当最后一个字符为字母时 遍历结束不会进入else中 所以需要再存一次字符串
        words.push_back(word);
    }

    for (int i = words.size() - 1; i >= 0; --i) {//将字符串数组倒着遍历一遍
        cout << words[i];
        if (i > 0) {
            cout << " ";
        }
    }

    return 0;
}