A, B= map(int, raw_input().split()) for num in range(A,B+1): l = [int(x) for x in list(str(num))] if num % 3 == 0: print num elif 3 in l: print num