






def     _snake_case    (__lowercase = 10    ,      __lowercase = 22				):
   UpperCamelCase_									=     range(1    ,      snake_case_				)
   UpperCamelCase_									=     range(1    ,      snake_case_				)
   return sum(
       1 for power in powers for base in bases if len(str(base**power				)				) == power				)


if __name__ == "__main__":
 print(f'{solution(1_0, 2_2) = }')













from typing import Any






def     _snake_case    (__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      ):
   _validation(
       __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      )
   # Creates data structures and fill initial step
   UpperCamelCase_									=     {}
   UpperCamelCase_									=     {}
   for state in states_space:
      UpperCamelCase_									=     observations_space[0]
      UpperCamelCase_									=     (
          initial_probabilities[state] * emission_probabilities[state][observation]
      )
      UpperCamelCase_									=     None

   # Fills the data structure with the probabilities of
   # different transitions and pointers to previous states
   for o in range(1    ,      len(__lowercase)):
      UpperCamelCase_									=     observations_space[o]
      UpperCamelCase_									=     observations_space[o - 1]
      for state in states_space:
         # Calculates the argmax for probability function
         UpperCamelCase_									=     ''
         UpperCamelCase_									=     -1
         for k_state in states_space:
            UpperCamelCase_									=     (
                probabilities[(k_state, prior_observation)]
                * transition_probabilities[k_state][state]
                * emission_probabilities[state][observation]
            )
            if probability > max_probability:
               UpperCamelCase_									=     probability
               UpperCamelCase_									=     k_state

            # Update probabilities and pointers dicts
         UpperCamelCase_									=     (
             probabilities[(arg_max, prior_observation)]
             * transition_probabilities[arg_max][state]
             * emission_probabilities[state][observation]
         )

         UpperCamelCase_									=     arg_max

    # The final observation
   UpperCamelCase_									=     observations_space[len(__lowercase) - 1]

   # argmax for given final observation
   UpperCamelCase_									=     ''
   UpperCamelCase_									=     -1
   for k_state in states_space:
      UpperCamelCase_									=     probabilities[(k_state, final_observation)]
      if probability > max_probability:
         UpperCamelCase_									=     probability
         UpperCamelCase_									=     k_state
   UpperCamelCase_									=     arg_max

   # Process pointers backwards
   UpperCamelCase_									=     last_state
   UpperCamelCase_									=     []
   for o in range(len(__lowercase) - 1    ,      -1    ,      -1):
      result.append(__lowercase)
      UpperCamelCase_									=     pointers[previous, observations_space[o]]
   result.reverse()

   return result






def     _snake_case    (__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      ):
   _validate_not_empty(
       __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      )
   _validate_lists(__lowercase    ,      __lowercase)
   _validate_dicts(
       __lowercase    ,      __lowercase    ,      __lowercase)






def     _snake_case    (__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase    ,      ):
   if not all(
       [
           observations_space,
           states_space,
           initial_probabilities,
           transition_probabilities,
           emission_probabilities,
       ]):
      raise ValueError('There\'s an empty parameter')






def     _snake_case    (__lowercase    ,      __lowercase):
   _validate_list(__lowercase    ,      'observations_space')
   _validate_list(__lowercase    ,      'states_space')






def     _snake_case    (__lowercase    ,      __lowercase):
   if not isinstance(_object    ,      __lowercase):
      UpperCamelCase_									=     f"""{var_name} must be a list"""
      raise ValueError(__lowercase)
   else:
      for x in _object:
         if not isinstance(__lowercase    ,      __lowercase):
            UpperCamelCase_									=     f"""{var_name} must be a list of strings"""
            raise ValueError(__lowercase)






def     _snake_case    (__lowercase    ,      __lowercase    ,      __lowercase    ,      ):
   _validate_dict(__lowercase    ,      'initial_probabilities'    ,      __lowercase)
   _validate_nested_dict(__lowercase    ,      'transition_probabilities')
   _validate_nested_dict(__lowercase    ,      'emission_probabilities')






def     _snake_case    (__lowercase    ,      __lowercase):
   _validate_dict(_object    ,      __lowercase    ,      __lowercase)
   for x in _object.values():
      _validate_dict(__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase)






def     _snake_case    (__lowercase    ,      __lowercase    ,      __lowercase    ,      __lowercase = False):
   if not isinstance(_object    ,      __lowercase):
      UpperCamelCase_									=     f"""{var_name} must be a dict"""
      raise ValueError(__lowercase)
   if not all(isinstance(__lowercase    ,      __lowercase) for x in _object):
      UpperCamelCase_									=     f"""{var_name} all keys must be strings"""
      raise ValueError(__lowercase)
   if not all(isinstance(__lowercase    ,      __lowercase) for x in _object.values()):
      UpperCamelCase_									=     'nested dictionary ' if nested else ''
      UpperCamelCase_									=     f"""{var_name} {nested_text}all values must be {value_type.__name__}"""
      raise ValueError(__lowercase)


if __name__ == "__main__":
 from doctest import testmod

 testmod()





