S = gets.chomp from = S.index('#') to = S.rindex('#') puts S[from + 1..to - 1]