Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/stack-fayl-yoli

Simplifying a file path

Medium 1000 ms 128 MB 58%
Share

In a file system a path consists of names separated by the character / and starts with / (the root folder). . is the current folder, .. is the folder one level up (at the root .. changes nothing), and several / in a row count as one /. Bring the given path to its simplest form: it starts with /, there is exactly one / between names, . and .. do not occur, and there is no / at the end (if it is the root itself, / is printed).

A folder tree: walked along the parts of the path, the folder reached at the end is highlighted

Input

One line with the path.

Output

The simplified path.

Note

the length of the path is from $1$ to $10^{4}$
names consist of $1$ to $8$ lowercase Latin letters and digits

Examples

Input #1
/home//user/./docs/../music/
Output #1
/home/user/music
Input #2
/../
Output #2
/

Sign in to submit a solution

Signing up is free and takes a minute.