{"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\u003eA binary string is a non-empty sequence of $$$0$$$\u0027s and $$$1$$$\u0027s, e.g., \u003cspan class\u003d\"tex-font-style-tt\"\u003e010110\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003e11101\u003c/span\u003e, etc. Ayu has a favorite binary string $$$S$$$ which contains no leading zeroes. She wants to convert $$$S$$$ into its \u003cspan class\u003d\"tex-font-style-bf\"\u003edecimal\u003c/span\u003e representation with her calculator.\u003c/p\u003e\u003cp\u003eUnfortunately, her calculator cannot work on any integer larger than $$$K$$$ and it will crash. Therefore, Ayu may need to remove zero or more bits from $$$S$$$ while maintaining the order of the remaining bits such that its decimal representation is no larger than $$$K$$$. The resulting binary string also must not contain any leading zeroes.\u003c/p\u003e\u003cp\u003eYour task is to help Ayu to determine the minimum number of bits to be removed from $$$S$$$ to satisfy Ayu\u0027s need.\u003c/p\u003e\u003cp\u003eFor example, let $$$S$$$ \u003d \u003cspan class\u003d\"tex-font-style-tt\"\u003e1100101\u003c/span\u003e and $$$K \u003d 13$$$. Note that \u003cspan class\u003d\"tex-font-style-tt\"\u003e1100101\u003c/span\u003e is $$$101$$$ in decimal representation, thus, we need to remove several bits from $$$S$$$ to make it no larger than $$$K$$$. We can remove the $$$3^{rd}$$$, $$$5^{th}$$$, and $$$6^{th}$$$ most significant bits, i.e. \u003cspan class\u003d\"tex-font-style-tt\"\u003e11\u003cspan class\u003d\"tex-font-style-underline\"\u003e0\u003c/span\u003e0\u003cspan class\u003d\"tex-font-style-underline\"\u003e1\u003c/span\u003e\u003cspan class\u003d\"tex-font-style-underline\"\u003e0\u003c/span\u003e1\u003c/span\u003e $$$\\rightarrow$$$ \u003cspan class\u003d\"tex-font-style-tt\"\u003e1101\u003c/span\u003e. The decimal representation of \u003cspan class\u003d\"tex-font-style-tt\"\u003e1101\u003c/span\u003e is $$$13$$$, which is no larger than $$$K \u003d 13$$$. In this example, we removed $$$3$$$ bits, and this is the minimum possible (If we remove only $$$2$$$ bits, then we will have a binary string of length $$$5$$$ bits; notice that any binary string of length $$$5$$$ bits has a value of at least $$$16$$$ in decimal representation).\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eInput begins with a line containing an integer $$$K$$$ ($$$1 \\le K \\le 2^{60}$$$) representing the limit of Ayu\u0027s calculator. The second line contains a binary string $$$S$$$ ($$$1 \\le |S| \\le 60$$$) representing Ayu\u0027s favorite binary string. You may safely assume $$$S$$$ contains no leading zeroes.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput contains an integer in a line representing the minimum number of bits to be removed from $$$S$$$.\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\u003e13\n1100101\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\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\u003e13\n1111111\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":"Note","value":{"format":"HTML","content":"\u003cp\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eExplanation for the sample input/output #1\u003c/span\u003e\u003c/p\u003e\u003cp\u003eThis sample is illustrated by the example given in the problem description above.\u003c/p\u003e\u003cp\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eExplanation for the sample input/output #2\u003c/span\u003e\u003c/p\u003e\u003cp\u003eAyu must remove $$$4$$$ bits to get \u003cspan class\u003d\"tex-font-style-tt\"\u003e111\u003c/span\u003e, which is $$$7$$$ in its decimal representation.\u003c/p\u003e"}}]}