n=0;exec"n+=1;i=n;exec'i=sum(int(d)**2for d in`i`);'*6\nif i<2:print n\n"*2000