object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt

    for (i <- 1 to n) {
      if ((n % 10 == 3) || (n % 3 == 0))
        print(" " + i.toString)
    }
    println

  }
}