#include #include using namespace std; bool is_u_turn(const char dir_pre, const char dir_cur) { return (dir_pre == 'R' && dir_cur == 'L') || (dir_pre == 'L' && dir_cur == 'R') || (dir_pre == 'U' && dir_cur == 'D') || (dir_pre == 'D' && dir_cur == 'U'); } string contract(const string& path) { string new_path = ""; for (const char &dir : path) { if (!new_path.empty() && is_u_turn(new_path.back(), dir)) { new_path.pop_back(); } else { new_path.push_back(dir); } } return new_path; } int main(void) { string path; cin >> path; string new_path = contract(path); cout << new_path << endl; return 0; }