{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eOne of Arkady\u0027s friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $$$s$$$ towards a faraway galaxy. Recently they\u0027ve received a response $$$t$$$ which they believe to be a response from aliens! The scientists now want to check if the signal $$$t$$$ is similar to $$$s$$$.\u003c/p\u003e\u003cp\u003eThe original signal $$$s$$$ was a sequence of zeros and ones (everyone knows that binary code is the universe-wide language). The returned signal $$$t$$$, however, does not look as easy as $$$s$$$, but the scientists don\u0027t give up! They represented $$$t$$$ as a sequence of English letters and say that $$$t$$$ is similar to $$$s$$$ if you can replace all zeros in $$$s$$$ with some string $$$r_0$$$ and all ones in $$$s$$$ with some other string $$$r_1$$$ and obtain $$$t$$$. The strings $$$r_0$$$ and $$$r_1$$$ must be different and non-empty.\u003c/p\u003e\u003cp\u003ePlease help Arkady\u0027s friend and find the number of possible replacements for zeros and ones (the number of pairs of strings $$$r_0$$$ and $$$r_1$$$) that transform $$$s$$$ to $$$t$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a string $$$s$$$ ($$$2 \\le |s| \\le 10^5$$$) consisting of zeros and ones\u0026nbsp;— the original signal.\u003c/p\u003e\u003cp\u003eThe second line contains a string $$$t$$$ ($$$1 \\le |t| \\le 10^6$$$) consisting of lowercase English letters only\u0026nbsp;— the received signal.\u003c/p\u003e\u003cp\u003eIt is guaranteed, that the string $$$s$$$ contains at least one \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e0\u003c/span\u003e\u0027 and at least one \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\u0027.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single integer\u0026nbsp;— the number of pairs of strings $$$r_0$$$ and $$$r_1$$$ that transform $$$s$$$ to $$$t$$$.\u003c/p\u003e\u003cp\u003eIn case there are no such pairs, print $$$0$$$.\u003c/p\u003e"}},{"title":"Examples","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\u003e01\naaaaaa\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\u003e001\nkokokokotlin\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, the possible pairs $$$(r_0, r_1)$$$ are as follows:\u003c/p\u003e\u003cul\u003e \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaaaa\u003c/span\u003e\" \u003c/li\u003e\u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaa\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaaa\u003c/span\u003e\" \u003c/li\u003e\u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaaa\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaa\u003c/span\u003e\" \u003c/li\u003e\u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaaaa\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\" \u003c/li\u003e\u003c/ul\u003e \u003cp\u003eThe pair \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaa\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaa\u003c/span\u003e\" is not allowed, since $$$r_0$$$ and $$$r_1$$$ must be different.\u003c/p\u003e\u003cp\u003eIn the second example, the following pairs are possible: \u003c/p\u003e\u003cul\u003e \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eko\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ekokotlin\u003c/span\u003e\" \u003c/li\u003e\u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ekoko\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003etlin\u003c/span\u003e\" \u003c/li\u003e\u003c/ul\u003e"}}]}