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