a, b = map(int, input().split()) # a ~ b をloopさせて i に代入 for i in range(a, b + 1): # 3 のつく数 と3の倍数を出力 if i % 3 == 0 or '3' in str(i): print(i)