(function (a, b) for i=a,b do if i%3==0 or tostring(i):find("3")~=nil then print(i) end end end)(io.stdin:read("*n"), io.stdin:read("*n"))