def main(): S,E = [int(x) for x in input().split()] for n in range(S,E+1): if n%3==0: print(n) elif '3' in str(n): print(n) if __name__ == "__main__": main()