N = list(map(int, input().split(' '))) A = N[0] B = N[1] while A <= B: if A % 3 == 0 or '3' in str(A): print(A) A += 1