{"raw_statement":[{"iden":"problem statement","content":"To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n*   $1$ yen (the currency of Japan)\n    \n*   $6$ yen, $6^2(=36)$ yen, $6^3(=216)$ yen, ...\n    \n*   $9$ yen, $9^2(=81)$ yen, $9^3(=729)$ yen, ...\n    \n\nAt least how many operations are required to withdraw exactly $N$ yen in total?\nIt is not allowed to re-deposit the money you withdrew."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 100000$\n*   $N$ is an integer."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$"},{"iden":"sample input 1","content":"127"},{"iden":"sample output 1","content":"4\n\nBy withdrawing $1$ yen, $9$ yen, $36(=6^2)$ yen and $81(=9^2)$ yen, we can withdraw $127$ yen in four operations."},{"iden":"sample input 2","content":"3"},{"iden":"sample output 2","content":"3\n\nBy withdrawing $1$ yen three times, we can withdraw $3$ yen in three operations."},{"iden":"sample input 3","content":"44852"},{"iden":"sample output 3","content":"16"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}