# -*- coding: utf-8 -*- #No.207 世界のなんとか a,b = map(int,raw_input().split()) ans = [] while(a<=b): if a % 3 == 0: ans.append(a) else: tmp = a while(tmp>10): if tmp%10 == 3: ans.append(a) tmp /= 10 a += 1 for i in xrange(len(ans)): print ans[i]