def h(n): if n<2:print i if n>6:return h(sum(map(lambda x:x*x,map(int,str(n))))) for i in range(1,2E3):h(i)