n=input() t=1 exec'while n*n%(t*100)-1:n+=t\nt*=10\n'*300 print n%t