import Data.Functor ((<$>)) isAho :: Int -> Bool isAho n = mod n 3 == 0 || isAhoDigit3 n where isAhoDigit3 0 = False isAhoDigit3 n' = mod n' 10 == 3 || isAhoDigit3 (div n' 10) main = do [a,b] <- map read . words <$> getLine mapM_ putStrLn $ map show $ filter isAho [a..b]