{"problem":{"name":"Base n","description":{"content":"Given are a string $X$ consisting of `0` through `9`, and an integer $M$. Let $d$ be the greatest digit in $X$. How many different integers not greater than $M$ can be obtained by choosing an integer ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc192_d"},"statements":[{"statement_type":"Markdown","content":"Given are a string $X$ consisting of `0` through `9`, and an integer $M$.\nLet $d$ be the greatest digit in $X$.\nHow many different integers not greater than $M$ can be obtained by choosing an integer $n$ not less than $d+1$ and seeing $X$ as a base-$n$ number?\n\n## Constraints\n\n*   $X$ consists of `0` through `9`.\n*   The length of $X$ is between $1$ and $60$ (inclusive).\n*   $X$ does not begin with a `0`.\n*   $1 \\leq M \\leq 10^{18}$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$X$\n$M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc192_d","tags":[],"sample_group":[["22\n10","2\n\nThe greatest digit in $X$ is `2`.\n\n*   By seeing $X$ as a base-$3$ number, we get $8$.\n*   By seeing $X$ as a base-$4$ number, we get $10$.\n\nThese two values are the only ones that we can obtain and are not greater than $10$."],["999\n1500","3\n\nThe greatest digit in $X$ is `9`.\n\n*   By seeing $X$ as a base-$10$ number, we get $999$.\n*   By seeing $X$ as a base-$11$ number, we get $1197$.\n*   By seeing $X$ as a base-$12$ number, we get $1413$.\n\nThese three values are the only ones that we can obtain and are not greater than $1500$."],["100000000000000000000000000000000000000000000000000000000000\n1000000000000000000","1\n\nBy seeing $X$ as a base-$2$ number, we get $576460752303423488$, which is the only value that we can obtain and are not greater than $1000000000000000000$."]],"created_at":"2026-03-03 11:01:14"}}