A,B=gets.split.map(&:to_i) for i in A..B do T=0,j=i while j>0 do if j%10==3 T=1 end j/=10 end if T==1 || i%3==0 puts i end end