{"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\"\u003e有一天,杰瑞发现了一台奇怪的打字机。这台打字机有$2$种输入模式:支付$p$个硬币将任意单个字母附加到末尾,或支付$q$个硬币复制已输出的子字符串并粘贴到末尾。\u003cbr\u003e现在杰瑞想给汤姆写一封信。这封信是一个字符串$S$,只包含小写拉丁字母。但由于杰瑞并不富裕,他想知道写这封信需要的最少硬币数量。\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"本问题包含多个测试用例。处理直到文件结束。\u003cbr\u003e对于每个测试用例,第一行包含字符串$S$($|S| \\le 2 \\times 10 ^ 5, \\sum |S| \\leq 5\\times 10 ^ 6$),只包含小写拉丁字母。第二行包含$2$个整数$p$和$q$($1 \\leq p,q \u0026lt; 2^{31}$)。"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,输出一行,包含杰瑞需要支付的最少硬币数量。"}},{"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\u003eabc\r\n1 2\r\naabaab\r\n2 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n6\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}