#include <bits/stdc++.h>
#define MOD 998244353
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define ui unsigned int
using namespace std;
const int maxn = 1e6+9;
int main()
{
string str;
getline(cin,str);
stack<char>st;
stack<string>s;
for (int i = 0; i < str.length(); i++)
{
if (i == str.length() - 1)
{
st.push(str[i]);
string cc = "";
while (!st.empty())
{
cc += st.top();
st.pop();
}
for (int i = 0; i < cc.length(); i++)
{
if (cc[i] >= 'a' && cc[i] <= 'z')
cc[i] += 32;
if (cc[i] >= 'A' && cc[i] <= 'Z')
cc[i] -= 32;
}
s.push(cc);
break;
}
if (str[i] == ' ')
{
string cc = "";
while (!st.empty())
{
cc += st.top();
st.pop();
}
for (int i = 0; i < cc.length(); i++)
{
if (cc[i] >= 'a' && cc[i] <= 'z')
cc[i] -= 32;
if (cc[i] >= 'A' && cc[i] <= 'Z')
cc[i] += 32;
}
s.push(cc);
}
else st.push(str[i]);
}
while (!s.empty())
{
cout << s.top() << '\n';
s.pop();
}
return 0;
}