import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto n = readln.chomp.to!int;

  foreach (i; 1..n + 1)
    if (i % 3 == 0 || i % 10 == 3) write(" ", i);

  writeln;
}