#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string capitalizeTitle(string title) {
int c = 0, idx = 0;
for (int i = 0; i < title.size(); i++) {
title[i] = tolower(title[i]);
}
for (int i = 0; i < title.size(); i++) {
if (title[i] != ' ') {
++c;
if (c == 1) {
idx = i;
}
}
if (title[i] == ' ' || (i + 1) == title.length()) {
if (c > 2) {
title[idx] = toupper(title[idx]);
}
c = 0;
}
}
// Capitalize the last character
if (!title.empty()) {
title[title.size() - 1] = toupper(title[title.size() - 1]);
}
return title;
}
int main() {
string s;
getline(cin, s);
cout << capitalizeTitle(s);
return 0;
}