Very simple question, but stuck in some special conditions and bugs, FINISHED in 40 mins