import Text.Printf

main = do
  x <- readLn
  mapM_ (printf . toString) $ solve x
  putStrLn ""

toString :: Int -> String
toString x = printf " %d" x

solve :: Int -> [Int]
solve x = filter (\y -> y `rem` 10 == 3 || y `rem` 3 == 0) [1..x]