{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eJohn von Neumann suggested in 1946 a method to create a sequence of pseudo-random numbers. His idea is known as the \"middle-square\"-method and works as follows: We choose an initial value a\u003csub\u003e0\u003c/sub\u003e, which has a decimal representation of length at most n. We then multiply the value a\u003csub\u003e0\u003c/sub\u003e by itself, add leading zeros until we get a decimal representation of length 2 × n and take the middle n digits to form a\u003csub\u003ei\u003c/sub\u003e. This process is repeated for each a\u003csub\u003ei\u003c/sub\u003e with i\u0026gt;0. In this problem we use n \u003d 4. \u003cbr\u003e\u003cbr\u003eExample 1: a\u003csub\u003e0\u003c/sub\u003e\u003d5555, a\u003csub\u003e0\u003c/sub\u003e\u003csup\u003e2\u003c/sup\u003e\u003d30858025, a\u003csub\u003e1\u003c/sub\u003e\u003d8580,... \u003cbr\u003e\u003cbr\u003eExample 2: a\u003csub\u003e0\u003c/sub\u003e\u003d1111, a\u003csub\u003e0\u003c/sub\u003e\u003csup\u003e2\u003c/sup\u003e\u003d01234321, a\u003csub\u003e1\u003c/sub\u003e\u003d2343,... \u003cbr\u003e\u003cbr\u003eUnfortunately, this random number generator is not very good. When started with an initial value it does not produce all other numbers with the same number of digits. \u003cbr\u003e\u003cbr\u003eYour task is to check for a given initial value a\u003csub\u003e0\u003c/sub\u003e how many different numbers are produced. \u003cbr\u003e\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains several test cases. Each test case consists of one line containing a\u003csub\u003e0\u003c/sub\u003e (0 \u0026lt; a\u003csub\u003e0\u003c/sub\u003e \u0026lt; 10000). Numbers are possibly padded with leading zeros such that each number consists of exactly 4 digits. The input is terminated with a line containing the value 0. \u003cbr\u003e\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a line containing the number of different values a\u003csub\u003ei\u003c/sub\u003e produced by this random number generator when started with the given value a\u003csub\u003e0\u003c/sub\u003e. Note that a\u003csub\u003e0\u003c/sub\u003e should also be counted. \u003cbr\u003e\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5555\r\n0815\r\n6239\r\n0\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e32\r\n17\r\n111\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eNote that the third test case has the maximum number of different values among all possible inputs. \u003cbr\u003e"}}]}