#coding: UTF-8 import sys import re import itertools from collections import deque ### defs ### def con3(x): while x > 0: if (x%10==3): return True x = x//10 return False ### main ### A, B = map(int, sys.stdin.readline().split()) ans = [] for x in range(A,B+1): if (x%3==0 or con3(x)): ans.append(x) for x in ans: print(x)