# -*- coding: utf-8 -*- A, B = map(int, input().split()) for i in range(A, B+1): if i % 3 == 0 and i != 0: print(i) else: quotient = i while quotient != 0: number = quotient % 10 if number == 3: print(i) break else: quotient //= 10