# -*- coding: utf-8 -*- def find_three(x): if x % 10 == 3: return x elif x >= 10: if find_three(x / 10) is not None: return x else: return None A, B = map(int, raw_input().split()) while(A <= B): if A % 3 == 0: print A elif find_three(A) is not None: print A A += 1