module Main (main) where

import Control.Applicative

call :: Int -> Int -> Int -> [Int] -> [Int]
call i x n xs
  | i > n           = reverse xs
  | x `mod` 3  == 0 = let i' = i + 1
                       in call i' i' n (i:xs)
  | x `mod` 10 == 3 = let i' = i + 1
                       in call i' i' n (i:xs)
  | otherwise       = let i' = i + 1
                       in call i' i' n xs

main :: IO ()
main = do
  n <- read <$> getLine
  putStrLn $ unwords $ "" : (map show $ call 1 1 n [])