

'''simple docstring'''
def  a__       (    _SCREAMING_SNAKE_CASE   :       int				)     ->					int:


	"""simple docstring"""





	UpperCAmelCase_     :      List[str]						=  0
	while num > 0:
		digit_sum += num % 10
		num //= 10
	return digit_sum


def  a__       (    _SCREAMING_SNAKE_CASE   :       int = 1_00				)     ->					int:


	"""simple docstring"""





	UpperCAmelCase_     :      Optional[int]						=  1
	UpperCAmelCase_     :      Any						=  2

	for i in range(2	,				max_n + 1				):
		UpperCAmelCase_     :      Optional[int]						=  pre_numerator
		UpperCAmelCase_     :      int						=  2 * i // 3 if i % 3 == 0 else 1
		UpperCAmelCase_     :      Any						=  cur_numerator
		UpperCAmelCase_     :      List[str]						=  e_cont * pre_numerator + temp

	return sum_digits(_SCREAMING_SNAKE_CASE				)


if __name__ == "__main__":
					print(f"""{solution() = }""")







'''simple docstring'''







from math import pow
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							UpperCAmelCase__,							)      ->      tuple[int, int]:
       if current_sum == needed_sum:
              # If the sum of the powers is equal to needed_sum, then we have a solution.
              solutions_count += 1
              return current_sum, solutions_count

       A_						       =   int(pow(UpperCAmelCase__,							UpperCAmelCase__					)					)
       if current_sum + i_to_n <= needed_sum:
              # If the sum of the powers is less than needed_sum, then continue adding powers.
              current_sum += i_to_n
              A_       ,      A_						       =   backtrack(
                  UpperCAmelCase__,							UpperCAmelCase__,							current_number + 1,							UpperCAmelCase__,							UpperCAmelCase__					)
              current_sum -= i_to_n
       if i_to_n < needed_sum:
              # If the power of i is less than needed_sum, then try with the next power.
              A_       ,      A_						       =   backtrack(
                  UpperCAmelCase__,							UpperCAmelCase__,							current_number + 1,							UpperCAmelCase__,							UpperCAmelCase__					)
       return current_sum, solutions_count
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      int:
       if not (1 <= needed_sum <= 10_00 and 2 <= power <= 10):
              raise ValueError(
                  """Invalid input\n"""
                  """needed_sum must be between 1 and 1000, power between 2 and 10."""					)

       return backtrack(UpperCAmelCase__,							UpperCAmelCase__,							1,							0,							0					)[1]  # Return the solutions_count


if __name__ == "__main__":
      import doctest

      doctest.testmod()
