


from math import pow

def   _UpperCAmelCase       (     UpperCAmelCase      :			int						,	UpperCAmelCase      :			int						,	UpperCAmelCase      :			int						,	UpperCAmelCase      :			int						,	UpperCAmelCase      :			int						,	):
      """simple docstring"""




      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

      __lowerCamelCase     :      str       						=						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
            __lowerCamelCase     :      Tuple       						=						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.
            __lowerCamelCase     :      str       						=						backtrack(
                UpperCAmelCase						,	UpperCAmelCase						,	current_number + 1						,	UpperCAmelCase						,	UpperCAmelCase      )
      return current_sum, solutions_count

def   _UpperCAmelCase       (     UpperCAmelCase      :			int						,	UpperCAmelCase      :			int      ):
      """simple docstring"""




      if not (1 <= needed_sum <= 1_000 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()







def   _UpperCAmelCase       (     ):
      """simple docstring"""




      __lowerCamelCase     :      Optional[int]       						=						[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

      __lowerCamelCase     :      str       						=						6
      __lowerCamelCase     :      Optional[int]       						=						1
      __lowerCamelCase     :      Optional[int]       						=						1_901

      __lowerCamelCase     :      Optional[Any]       						=						0

      while year < 2_001:
            day += 7

            if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
                  if day > days_per_month[month - 1] and month != 2:
                        month += 1
                        __lowerCamelCase     :      Tuple       						=						day - days_per_month[month - 2]
                  elif day > 29 and month == 2:
                        month += 1
                        __lowerCamelCase     :      str       						=						day - 29
            else:
                  if day > days_per_month[month - 1]:
                        month += 1
                        __lowerCamelCase     :      Any       						=						day - days_per_month[month - 2]

            if month > 12:
                  year += 1
                  __lowerCamelCase     :      Optional[Any]       						=						1

            if year < 2_001 and day == 1:
                  sundays += 1
      return sundays


if __name__ == "__main__":
    print(solution())



