A, B = map( int, input().split() ) N = B - A + 1 for i in range(N): X = A + i Number = str(X) if X % 3 == 0 or Number.find('3') > -1: print(X)