solve :: Int ->	Int -> [String]
solve i	n
  | i > n = []
  | mod i 3 == 0 || mod i 10 == 3 || div i 10 == 3 = " " : show i : solve (i+1) n
  | otherwise = solve (i+1) n

main = readLn >>= putStrLn . concat . solve 1