




import copy
from typing import Dict

from ...generation.configuration_utils import GenerationConfig
from ...utils import logging


_lowerCAmelCase     :			List[Any]    =logging.get_logger(__name__)

class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "semantic"





					def __init__(							self							,			lowerCamelCase__=1_0_0_0_0							,			lowerCamelCase__=True							,			lowerCamelCase__=7_6_8							,			lowerCamelCase__=False							,			lowerCamelCase__=False							,			lowerCamelCase__=False							,			lowerCamelCase__=False							,			lowerCamelCase__=0.7							,			lowerCamelCase__=True							,			lowerCamelCase__=1_0_0_4_8							,			lowerCamelCase__=1_2_9_5_9_5							,			lowerCamelCase__=1_2_9_5_9_9							,			lowerCamelCase__=1_0_0_0_0							,			lowerCamelCase__=2_5_6							,			lowerCamelCase__=49.9							,			**lowerCamelCase__							,			):
						super().__init__(
						    temperature=lowerCamelCase__							,			do_sample=lowerCamelCase__							,			eos_token_id=lowerCamelCase__							,			renormalize_logits=lowerCamelCase__							,			max_new_tokens=lowerCamelCase__							,			output_scores=lowerCamelCase__							,			return_dict_in_generate=lowerCamelCase__							,			output_hidden_states=lowerCamelCase__							,			output_attentions=lowerCamelCase__							,			**lowerCamelCase__							,			)

						UpperCAmelCase__:  Dict		       =   text_encoding_offset
						UpperCAmelCase__:  List[Any]		       =   text_pad_token
						UpperCAmelCase__:  Optional[int]		       =   eos_token_id
						UpperCAmelCase__:  Any		       =   semantic_infer_token
						UpperCAmelCase__:  Optional[Any]		       =   semantic_vocab_size
						UpperCAmelCase__:  List[Any]		       =   max_input_semantic_length
						UpperCAmelCase__:  List[Any]		       =   semantic_rate_hz

class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "coarse_acoustics"





					def __init__(							self							,			lowerCamelCase__=True							,			lowerCamelCase__=False							,			lowerCamelCase__=False							,			lowerCamelCase__=False							,			lowerCamelCase__=False							,			lowerCamelCase__=0.7							,			lowerCamelCase__=True							,			lowerCamelCase__=1_2_0_4_8							,			lowerCamelCase__=7_5							,			lowerCamelCase__=2							,			lowerCamelCase__=1_2_0_5_0							,			lowerCamelCase__=2_5_6							,			lowerCamelCase__ = 6_3_0							,			lowerCamelCase__ = 6_0							,			**lowerCamelCase__							,			):
						super().__init__(
						    temperature=lowerCamelCase__							,			do_sample=lowerCamelCase__							,			renormalize_logits=lowerCamelCase__							,			output_scores=lowerCamelCase__							,			return_dict_in_generate=lowerCamelCase__							,			output_hidden_states=lowerCamelCase__							,			output_attentions=lowerCamelCase__							,			**lowerCamelCase__							,			)

						UpperCAmelCase__:  int		       =   coarse_semantic_pad_token
						UpperCAmelCase__:  Tuple		       =   coarse_rate_hz
						UpperCAmelCase__:  Optional[int]		       =   n_coarse_codebooks
						UpperCAmelCase__:  Tuple		       =   coarse_infer_token
						UpperCAmelCase__:  str		       =   max_coarse_input_length
						UpperCAmelCase__:  Dict		       =   max_coarse_history
						UpperCAmelCase__:  Any		       =   sliding_window_len

class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "fine_acoustics"





					def __init__(							self							,			lowerCamelCase__=0.5							,			lowerCamelCase__=5_1_2							,			lowerCamelCase__=1_0_2_4							,			lowerCamelCase__=8							,			**lowerCamelCase__							,			):
						super().__init__(temperature=lowerCamelCase__	)

						UpperCAmelCase__:  Optional[Any]		       =   max_fine_history_length
						UpperCAmelCase__:  Any		       =   max_fine_input_length
						UpperCAmelCase__:  int		       =   n_fine_codebooks

class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "bark"
					__magic_name__     			=      True





					def __init__(							self							,			lowerCamelCase__ = None							,			lowerCamelCase__ = None							,			lowerCamelCase__ = None							,			lowerCamelCase__=2_4_0_0_0							,			lowerCamelCase__=1_0_2_4							,			**lowerCamelCase__							,			):
						if semantic_config is None:
							UpperCAmelCase__:  List[str]		       =   {}
							logger.info("semantic_config is None. initializing the semantic model with default values."	)

						if coarse_acoustics_config is None:
							UpperCAmelCase__:  Dict		       =   {}
							logger.info("coarse_acoustics_config is None. initializing the coarse model with default values."	)

						if fine_acoustics_config is None:
							UpperCAmelCase__:  int		       =   {}
							logger.info("fine_acoustics_config is None. initializing the fine model with default values."	)

						UpperCAmelCase__:  Tuple		       =   BarkSemanticGenerationConfig(**lowerCamelCase__	)
						UpperCAmelCase__:  List[str]		       =   BarkCoarseGenerationConfig(**lowerCamelCase__	)
						UpperCAmelCase__:  List[str]		       =   BarkFineGenerationConfig(**lowerCamelCase__	)

						UpperCAmelCase__:  List[str]		       =   sample_rate
						UpperCAmelCase__:  int		       =   codebook_size





					@classmethod
					def       _UpperCAmelCase						(							cls							,			lowerCamelCase__							,			lowerCamelCase__							,			lowerCamelCase__							,			**lowerCamelCase__							,			):
						return cls(
						    semantic_config=semantic_config.to_dict()							,			coarse_acoustics_config=coarse_acoustics_config.to_dict()							,			fine_acoustics_config=fine_acoustics_config.to_dict()							,			**lowerCamelCase__							,			)





					def       _UpperCAmelCase						(							self	):
						UpperCAmelCase__:  List[str]		       =   copy.deepcopy(self.__dict__	)

						UpperCAmelCase__:  Tuple		       =   self.semantic_config.to_dict()
						UpperCAmelCase__:  List[str]		       =   self.coarse_acoustics_config.to_dict()
						UpperCAmelCase__:  Optional[int]		       =   self.fine_acoustics_config.to_dict()

						UpperCAmelCase__:  List[Any]		       =   self.__class__.model_type
						return output


from __future__ import annotations

from collections import Counter



def  _A  (			SCREAMING_SNAKE_CASE			):
	UpperCAmelCase__:  Optional[Any]		       =   [True] * n
	UpperCAmelCase__:  Any		       =   False
	UpperCAmelCase__:  Tuple		       =   False
	UpperCAmelCase__:  Optional[Any]		       =   True

	for i in range(3  ,int(n**0.5 + 1			)  ,2			):
		UpperCAmelCase__:  Any		       =   i * 2
		while index < n:
			UpperCAmelCase__:  Optional[int]		       =   False
			UpperCAmelCase__:  Tuple		       =   index + i

	UpperCAmelCase__:  int		       =   [2]

	for i in range(3  ,SCREAMING_SNAKE_CASE  ,2			):
		if is_prime[i]:
			primes.append(SCREAMING_SNAKE_CASE			)

	return primes



def  _A  (			SCREAMING_SNAKE_CASE			):
	UpperCAmelCase__:  List[Any]		       =   str(SCREAMING_SNAKE_CASE			)
	UpperCAmelCase__:  Tuple		       =   []
	UpperCAmelCase__:  Optional[int]		       =   ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

	for duplicate in Counter(SCREAMING_SNAKE_CASE			) - Counter(set(SCREAMING_SNAKE_CASE			)			):
		UpperCAmelCase__:  Optional[Any]		       =   [int(number_str.replace(SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE			)			) for digit in digits]
		replacements.append(SCREAMING_SNAKE_CASE			)

	return replacements



def  _A  (			SCREAMING_SNAKE_CASE = 8			):
	UpperCAmelCase__:  Union[str, Any]		       =   set()

	# Filter primes with less than 3 replaceable digits
	UpperCAmelCase__:  Optional[Any]		       =   {
	    x for x in set(prime_sieve(1_0_0_0_0_0_0			)			) if len(str(SCREAMING_SNAKE_CASE			)			) - len(set(str(SCREAMING_SNAKE_CASE			)			)			) >= 3
	}

	for prime in primes:
		if prime in numbers_checked:
			continue

		UpperCAmelCase__:  Optional[int]		       =   digit_replacements(SCREAMING_SNAKE_CASE			)

		for family in replacements:
			numbers_checked.update(SCREAMING_SNAKE_CASE			)
			UpperCAmelCase__:  Dict		       =   primes.intersection(SCREAMING_SNAKE_CASE			)

			if len(SCREAMING_SNAKE_CASE			) != family_length:
				continue

			return min(SCREAMING_SNAKE_CASE			)

	return -1


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