a,b=map(int,raw_input().split()) while a<=b: if"3"in`a`or sum(int(b)for b in`a`)%3<1:print a a+=1