s = input().split() A = int(s[0]) B = int(s[1]) for i in range(A, B + 1): tmp = str(i) if i % 3 == 0 or '3' in tmp: print(i)