A,B = map(int,input().split())
if A % 3 == 0:
    start = A
elif (A+1) % 3 == 0:
    start = A+1
elif (A+2) % 3 == 0:
    start = A+2
L = []
for i in range(start,B+1,3):
    L.append(i)
for i in range(A,B+1):
    if '3' in list(str(i)):
        L.append(i)
S = set(L)
for i in sorted(S):
    print(i)