/*
与 HJ12 和 HJ13类似。
    本题比前面的多了 判断字符是否是字母的操作
*/

#include <algorithm>
#include <cctype>
#include <iostream>
using namespace std;

string reverseStr(string str) {
    int len = str.length();
    string ans;
    // 非字母用空格代替
    for(auto c : str){
    if( isalpha(c) ){
            ans.append(1, c);
        }else{
            ans.append(1, ' ');
        }
    }

    reverse(ans.begin(), ans.end());

    len = ans.length();
    for (int i = 0; i < len; ++i) {
        int j = i;
        while (ans[j] != ' ' && j < len) {
            j++;
        }
        reverse(ans.begin() + i, ans.begin() + j);
        i = j;
    }

    return ans;
}

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

    cout << reverseStr(str) << endl;

    return 0;
}
// 64 位输出请用 printf("%lld")