words = gets.delete(",.").split(" ").select{|word|
  3 <= word.size && word.size <= 6
}.group_by{|word|
  word
}.map{|k, v|
  k
}

print words[0]
for i in 1..words.size-1
  print " #{words[i]}"
end

puts ""