for x in range(2000): n=`x` while n!=4 and n>1: n=sum(int(i)**2 for i in str(n)) if n==1: print x