f n = (n`mod`3==0)||(elem '3' (show n)) main=do [a,b]<-getLine>>=return.map(read::String->Integer).words mapM_ print$[x|x<-[a..b],f x]