def main(): min_val, max_val = [int(val) for val in input().split()] for val in range(min_val, max_val): if (val % 3) == 0 or (str(val).find('3')) >= 0: print(val) if __name__ == '__main__': main()