





"""simple docstring"""
from dataclasses import dataclass

lowerCamelCase_          =	"0.1"
lowerCamelCase_          =	"Lucia Harcekova"






@dataclass
class       _SCREAMING_SNAKE_CASE:
       SCREAMING_SNAKE_CASE_     :   int
       SCREAMING_SNAKE_CASE_     :   int
       SCREAMING_SNAKE_CASE_     :   str




       def __repr__(		self							)    ->   str:





             """simple docstring"""






             return f'''({self.offset}, {self.length}, {self.indicator})'''






class       _SCREAMING_SNAKE_CASE:




       def __init__(		self	,SCREAMING_SNAKE_CASE__ = 13	,SCREAMING_SNAKE_CASE__ = 6							)    ->   None:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE     :Tuple	       =						window_size
             __SCREAMING_SNAKE_CASE     :List[str]	       =						lookahead_buffer_size
             __SCREAMING_SNAKE_CASE     :str	       =						self.window_size - self.lookahead_buffer_size




       def 					_UpperCamelCase  (		self	,SCREAMING_SNAKE_CASE__							)    ->   list[Token]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE     :Union[str, Any]	       =						[]
             __SCREAMING_SNAKE_CASE     :List[str]	       =						''''''

             # while there are still characters in text to compress
             while text:
                   # find the next encoding phrase
                   # - triplet with offset, length, indicator (the next encoding character)
                   __SCREAMING_SNAKE_CASE     :Optional[int]	       =						self._find_encoding_token(SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__							)

                   # update the search buffer:
                   # - add new characters from text into it
                   # - check if size exceed the max search buffer size, if so, drop the
                   #   oldest elements
                   search_buffer += text[: token.length + 1]
                   if len(SCREAMING_SNAKE_CASE__							) > self.search_buffer_size:
                         __SCREAMING_SNAKE_CASE     :List[Any]	       =						search_buffer[-self.search_buffer_size :]

                   # update the text
                   __SCREAMING_SNAKE_CASE     :List[Any]	       =						text[token.length + 1 :]

                   # append the token to output
                   output.append(SCREAMING_SNAKE_CASE__							)

             return output




       def 					_UpperCamelCase  (		self	,SCREAMING_SNAKE_CASE__							)    ->   str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE     :List[Any]	       =						''''''

             for token in tokens:
                   for _ in range(token.length							):
                         output += output[-token.offset]
                   output += token.indicator

             return output




       def 					_UpperCamelCase  (		self	,SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__							)    ->   Token:





             """simple docstring"""






             if not text:
                   raise ValueError('''We need some text to work with.'''							)

             # Initialise result parameters to default values
             __SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE     :Dict	       =						0, 0

             if not search_buffer:
                   return Token(SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__	,text[length]							)

             for i, character in enumerate(SCREAMING_SNAKE_CASE__							):
                   __SCREAMING_SNAKE_CASE     :List[Any]	       =						len(SCREAMING_SNAKE_CASE__							) - i
                   if character == text[0]:
                         __SCREAMING_SNAKE_CASE     :Optional[Any]	       =						self._match_length_from_index(SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__	,0	,SCREAMING_SNAKE_CASE__							)
                         # if the found length is bigger than the current or if it's equal,
                         # which means it's offset is smaller: update offset and length
                         if found_length >= length:
                               __SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE     :List[str]	       =						found_offset, found_length

             return Token(SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__	,text[length]							)




       def 					_UpperCamelCase  (		self	,SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__							)    ->   int:





             """simple docstring"""






             if not text or text[text_index] != window[window_index]:
                   return 0
             return 1 + self._match_length_from_index(
                 SCREAMING_SNAKE_CASE__	,window + text[text_index]	,text_index + 1	,window_index + 1							)


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

  testmod()
  # Initialize compressor class
  lowerCamelCase_          =	LZaaCompressor(window_size=1_3, lookahead_buffer_size=6)

  # Example
  lowerCamelCase_          =	"cabracadabrarrarrad"
  lowerCamelCase_          =	lzaa_compressor.compress(TEXT)
  print(lzaa_compressor.compress("ababcbababaa"))
  lowerCamelCase_          =	lzaa_compressor.decompress(compressed_text)
  assert decompressed_text == TEXT, "The LZ77 algorithm returned the invalid result."






"""simple docstring"""
def   __lowerCamelCase     (							a_  :	int = 10**6							)    ->   int:

      if n <= 0:
            raise ValueError('''Please enter an integer greater than 0'''							)

      __SCREAMING_SNAKE_CASE     :Tuple	       =						list(range(n + 1							)							)
      for number in range(2				,     n + 1							):
            if phi[number] == number:
                  phi[number] -= 1
                  for multiple in range(number * 2				,     n + 1				,     a_							):
                        __SCREAMING_SNAKE_CASE     :List[Any]	       =						(phi[multiple] // number) * (number - 1)

      __SCREAMING_SNAKE_CASE     :Optional[Any]	       =						1
      for number in range(1				,     n + 1							):
            if (answer / phi[answer]) < (number / phi[number]):
                  __SCREAMING_SNAKE_CASE     :str	       =						number

      return answer


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