

"""simple docstring"""



from math import pow





def  _snake_case     (    UpperCAmelCase_  :					int					,   UpperCAmelCase_  :					int					,   UpperCAmelCase_  :					int					,   UpperCAmelCase_  :					int					,   UpperCAmelCase_  :					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  _snake_case     (    UpperCAmelCase_  :					int					,   UpperCAmelCase_  :					int			):
     if not (1 <= needed_sum <= 1000 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()









"""simple docstring"""



from collections import defaultdict





def  _snake_case     (    UpperCAmelCase_  :					int			):
     A__										=  1
     A__										=  True
     for v in tree[start]:
          if v not in visited:
               ret += dfs(UpperCAmelCase_			)
     if ret % 2 == 0:
          cuts.append(UpperCAmelCase_			)
     return ret





def  _snake_case     (    ):
     dfs(1			)


if __name__ == "__main__":
 SCREAMING_SNAKE_CASE_  ,SCREAMING_SNAKE_CASE_					:	Any							  =						1_0, 9
 SCREAMING_SNAKE_CASE_					:	Any							  =						defaultdict(list)
 SCREAMING_SNAKE_CASE_					:	dict[int, bool]							  =						{}
 SCREAMING_SNAKE_CASE_					:	list[int]							  =						[]
 SCREAMING_SNAKE_CASE_					:	Optional[int]							  =						0
 SCREAMING_SNAKE_CASE_					:	Any							  =						[(2, 1), (3, 1), (4, 3), (5, 2), (6, 1), (7, 2), (8, 6), (9, 8), (1_0, 8)]
 for u, v in edges:
  tree[u].append(v)
  tree[v].append(u)
 even_tree()
 print(len(cuts) - 1)






