for i in range(1,2001): j=i while i not in[1,4]:s=0;exec's+=(i%10)**2;i/=10;'*4;i=s if i<2:print j