## DESCRIPTION 

Now please implement the solution in python. Read in the input from stdin; do not return anything. The script should print the result with print() or sys.stdout.write().
It should terminate within 30 seconds.
