A = gets.to_i B = gets.to_i for i in A..B num = i.to_s if i%3 == 0 print i,"\n" elsif /3/ =~ num print i,"\n" end end