{"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\u003eYou\u0027ve got string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e, consisting of small English letters. Some of the English letters are \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e, the rest are \u003cspan class\u003d\"tex-font-style-it\"\u003ebad\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eA substring \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e[\u003ci\u003el\u003c/i\u003e...\u003ci\u003er\u003c/i\u003e]\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003el\u003c/i\u003e ≤ \u003ci\u003er\u003c/i\u003e ≤ |\u003ci\u003es\u003c/i\u003e|\u003c/span\u003e) of string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e \u003d \u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e...\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e|\u003ci\u003es\u003c/i\u003e|\u003c/sub\u003e\u003c/span\u003e (where \u003cspan class\u003d\"tex-span\"\u003e|\u003ci\u003es\u003c/i\u003e|\u003c/span\u003e is the length of string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e) is string \u003cspan class\u003d\"tex-span\"\u003e \u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003el\u003c/i\u003e\u003c/sub\u003e\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003el\u003c/i\u003e + 1\u003c/sub\u003e...\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003er\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eThe substring \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e[\u003ci\u003el\u003c/i\u003e...\u003ci\u003er\u003c/i\u003e]\u003c/span\u003e is \u003cspan class\u003d\"tex-font-style-it\"\u003egood\u003c/span\u003e, if among the letters \u003cspan class\u003d\"tex-span\"\u003e \u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003el\u003c/i\u003e\u003c/sub\u003e, \u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003el\u003c/i\u003e + 1\u003c/sub\u003e, ..., \u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003er\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e there are \u003cspan class\u003d\"tex-font-style-bf\"\u003eat most\u003c/span\u003e \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ek\u003c/i\u003e\u003c/span\u003e \u003cspan class\u003d\"tex-font-style-bf\"\u003ebad\u003c/span\u003e ones (look at the sample\u0027s explanation to understand it more clear).\u003c/p\u003e\u003cp\u003eYour task is to find the number of distinct good substrings of the given string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e. Two substrings \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e[\u003ci\u003ex\u003c/i\u003e...\u003ci\u003ey\u003c/i\u003e]\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e[\u003ci\u003ep\u003c/i\u003e...\u003ci\u003eq\u003c/i\u003e]\u003c/span\u003e are considered distinct if their content is different, i.e. \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e[\u003ci\u003ex\u003c/i\u003e...\u003ci\u003ey\u003c/i\u003e] ≠ \u003ci\u003es\u003c/i\u003e[\u003ci\u003ep\u003c/i\u003e...\u003ci\u003eq\u003c/i\u003e]\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input is the non-empty string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e, consisting of small English letters, the string\u0027s length is at most \u003cspan class\u003d\"tex-span\"\u003e1500\u003c/span\u003e characters.\u003c/p\u003e\u003cp\u003eThe second line of the input is the string of characters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e0\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\", the length is exactly 26 characters. If the \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e-th character of this string equals \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\", then the \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e-th English letter is good, otherwise it\u0027s bad. That is, the first character of this string corresponds to letter \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", the second one corresponds to letter \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\" and so on.\u003c/p\u003e\u003cp\u003eThe third line of the input consists a single integer \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ek\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e0 ≤ \u003ci\u003ek\u003c/i\u003e ≤ |\u003ci\u003es\u003c/i\u003e|\u003c/span\u003e) — the maximum acceptable number of bad characters in a good substring.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single integer — the number of distinct good substrings of string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e.\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\u003eababab\n01000000000000000000000000\n1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\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\u003eacbacbacaa\n00000000000000000000000000\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\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 there are following good substrings: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eab\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eba\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebab\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eIn the second example there are following good substrings: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaa\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eac\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eba\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eca\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ecb\u003c/span\u003e\".\u003c/p\u003e"}}]}