A, B = list(map(int,input().split(" "))) List = [] for i in range(A, B+1): List.append(i) for j in range(0,len(List)): if List[j] % 3 == 0 or str(List[j]).find("3") >= 0 : print(List[j]) else: pass