from pip._vendor.requests.packages.urllib3.connectionpool import xrange first = input() s = first.split() a = int(s[0]) b = int(s[1]) for i in xrange(a,b+1): if i % 3 == 0 or str(i).find("3") != -1: print(i)