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