import sys readline=sys.stdin.readline A,B=map(int,readline().split()) for ans in range(A,B+1): if "3" in str(ans) or ans%3==0: print(ans)