first=input() # 読み込んだ文字列をスペースで分割する split_first = first.split() # それぞれをint型に変換する A = int(split_first[0]) B = int(split_first[1]) list_num=[] C=0 for i in range(A,B+1): if i%3==0 and i!=0: list_num.append(i) C+=1 if (i/10==3 or i%10==3) and i!=0: list_num.append(i) C+=1 print(sorted(set(list_num)))