import sys import re a = [int(x) for x in input().split()] start = a[0] end = a[1] for i in range(start ,end) : match = re.search('3', str(i)) if i % 3 == 0 : print(i) elif match : print(i)