A,B=map(int,input().split()) for nabeatsu in range(A,B+1): if ("3" in str(nabeatsu) or nabeatsu%3==0): print(nabeatsu,end="\n")