def main(): a, b = input().rstrip().split(" ") a = int(a) b = int(b) def has_three(strings): for j in strings: if "3" in j: return True return False for i in range(a, b + 1): if i % 3 == 0: print(i) elif has_three(str(i)): print(i) if __name__ == "__main__": main()