def main(): i = input() lst = i.split(' ') A,B = map(int, lst) a = [i for i in range(A,B+1)] for e in a: if '3' in str(e) or e%3 == 0: print(e) if __name__ == '__main__': main()