# -*- coding: utf-8 -*- def main(): numbers = [int(box) for box in input().split()] num = numbers[0] while num <= numbers[1]: a = str(num).split('3') if num % 3 == 0: print(num) elif len(a) > 1: print(num) num += 1 if __name__ == "__main__": main()