

'''simple docstring'''
import os
import re
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


_snake_case     =  logging.get_logger(__name__)

_snake_case     =  {
    'vocab_file': 'vocab.txt',
    'merges_file': 'bpe.codes',
}

_snake_case     =  {
    'vocab_file': {
        'vinai/phobert-base': 'https://huggingface.co/vinai/phobert-base/resolve/main/vocab.txt',
        'vinai/phobert-large': 'https://huggingface.co/vinai/phobert-large/resolve/main/vocab.txt',
    },
    'merges_file': {
        'vinai/phobert-base': 'https://huggingface.co/vinai/phobert-base/resolve/main/bpe.codes',
        'vinai/phobert-large': 'https://huggingface.co/vinai/phobert-large/resolve/main/bpe.codes',
    },
}

_snake_case     =  {
    'vinai/phobert-base': 256,
    'vinai/phobert-large': 256,
}







def 					_A		(	snake_case     )			->	int:
   _lowercase			:      List[str]			     =   set()
   _lowercase			:      int			     =   word[0]
   for char in word[1:]:
      pairs.add((prev_char, char)     )
      _lowercase			:      Optional[Any]			     =   char

   _lowercase			:      int			     =   set(__UpperCAmelCase     )
   return pairs


class    a__  (							_UpperCAmelCase  ):
   _SCREAMING_SNAKE_CASE    :     Any	       =							VOCAB_FILES_NAMES
   _SCREAMING_SNAKE_CASE    :     Optional[int]	       =							PRETRAINED_VOCAB_FILES_MAP
   _SCREAMING_SNAKE_CASE    :     str	       =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES


   def __init__( self			,				_UpperCamelCase			,				_UpperCamelCase			,				_UpperCamelCase="<s>"			,				_UpperCamelCase="</s>"			,				_UpperCamelCase="</s>"			,				_UpperCamelCase="<s>"			,				_UpperCamelCase="<unk>"			,				_UpperCamelCase="<pad>"			,				_UpperCamelCase="<mask>"			,				**_UpperCamelCase			,				):





      """simple docstring"""





      super().__init__(
          bos_token=_UpperCAmelCase			,				eos_token=_UpperCAmelCase			,				unk_token=_UpperCAmelCase			,				sep_token=_UpperCAmelCase			,				cls_token=_UpperCAmelCase			,				pad_token=_UpperCAmelCase			,				mask_token=_UpperCAmelCase			,				**_UpperCAmelCase			,				)

      _lowercase			:      Any			     =   vocab_file
      _lowercase			:      str			     =   merges_file

      _lowercase			:      str			     =   {}
      _lowercase			:      int			     =   0
      _lowercase			:      Any			     =   1
      _lowercase			:      Optional[int]			     =   2
      _lowercase			:      Optional[int]			     =   3

      self.add_from_file(_UpperCAmelCase  )

      _lowercase			:      Optional[int]			     =   {v: k for k, v in self.encoder.items()}

      with open(_UpperCAmelCase			,				encoding="utf-8"  ) as merges_handle:
         _lowercase			:      Any			     =   merges_handle.read().split("\n"  )[:-1]
      _lowercase			:      List[str]			     =   [tuple(merge.split()[:-1]  ) for merge in merges]
      _lowercase			:      Optional[int]			     =   dict(zip(_UpperCAmelCase			,				range(len(_UpperCAmelCase  )  )  )  )
      _lowercase			:      Tuple			     =   {}


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase			,				_UpperCamelCase = None  ):





      """simple docstring"""





      if token_ids_a is None:
         return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
      _lowercase			:      Dict			     =   [self.cls_token_id]
      _lowercase			:      Optional[Any]			     =   [self.sep_token_id]
      return cls + token_ids_a + sep + sep + token_ids_a + sep


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase			,				_UpperCamelCase = None			,				_UpperCamelCase = False  ):





      """simple docstring"""





      if already_has_special_tokens:
         return super().get_special_tokens_mask(
             token_ids_a=_UpperCAmelCase			,				token_ids_a=_UpperCAmelCase			,				already_has_special_tokens=_UpperCAmelCase  )

      if token_ids_a is None:
         return [1] + ([0] * len(_UpperCAmelCase  )) + [1]
      return [1] + ([0] * len(_UpperCAmelCase  )) + [1, 1] + ([0] * len(_UpperCAmelCase  )) + [1]


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase			,				_UpperCamelCase = None  ):





      """simple docstring"""





      _lowercase			:      Any			     =   [self.sep_token_id]
      _lowercase			:      str			     =   [self.cls_token_id]

      if token_ids_a is None:
         return len(cls + token_ids_a + sep  ) * [0]
      return len(cls + token_ids_a + sep + sep + token_ids_a + sep  ) * [0]


   @property
   def 						_lowerCamelCase   ( self  ):





      """simple docstring"""





      return len(self.encoder  )


   def 						_lowerCamelCase   ( self  ):





      """simple docstring"""





      return dict(self.encoder			,				**self.added_tokens_encoder  )


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase  ):





      """simple docstring"""





      if token in self.cache:
         return self.cache[token]
      _lowercase			:      Any			     =   tuple(_UpperCAmelCase  )
      _lowercase			:      Union[str, Any]			     =   tuple(list(word[:-1]  ) + [word[-1] + "</w>"]  )
      _lowercase			:      int			     =   get_pairs(_UpperCAmelCase  )

      if not pairs:
         return token

      while True:
         _lowercase			:      List[Any]			     =   min(_UpperCAmelCase			,				key=lambda _UpperCamelCase  : self.bpe_ranks.get(_UpperCAmelCase			,				float("inf"  )  )  )
         if bigram not in self.bpe_ranks:
            break
         _lowercase			:      Optional[int]			     =   bigram
         _lowercase			:      str			     =   []
         _lowercase			:      Optional[Any]			     =   0
         while i < len(_UpperCAmelCase  ):
            try:
               _lowercase			:      List[str]			     =   word.index(_UpperCAmelCase			,				_UpperCAmelCase  )
            except ValueError:
               new_word.extend(word[i:]  )
               break
            else:
               new_word.extend(word[i:j]  )
               _lowercase			:      Any			     =   j

            if word[i] == first and i < len(_UpperCAmelCase  ) - 1 and word[i + 1] == second:
               new_word.append(first + second  )
               i += 2
            else:
               new_word.append(word[i]  )
               i += 1
         _lowercase			:      Union[str, Any]			     =   tuple(_UpperCAmelCase  )
         _lowercase			:      str			     =   new_word
         if len(_UpperCAmelCase  ) == 1:
            break
         else:
            _lowercase			:      List[Any]			     =   get_pairs(_UpperCAmelCase  )
      _lowercase			:      str			     =   '''@@ '''.join(_UpperCAmelCase  )
      _lowercase			:      Union[str, Any]			     =   word[:-4]
      _lowercase			:      Union[str, Any]			     =   word
      return word


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase  ):





      """simple docstring"""





      _lowercase			:      Union[str, Any]			     =   []

      _lowercase			:      Any			     =   re.findall(R"\S+\n?"			,				_UpperCAmelCase  )

      for token in words:
         split_tokens.extend(list(self.bpe(_UpperCAmelCase  ).split(" "  )  )  )
      return split_tokens


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase  ):





      """simple docstring"""





      return self.encoder.get(_UpperCAmelCase			,				self.encoder.get(self.unk_token  )  )


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase  ):





      """simple docstring"""





      return self.decoder.get(_UpperCAmelCase			,				self.unk_token  )


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase  ):





      """simple docstring"""





      _lowercase			:      Optional[int]			     =   ''' '''.join(_UpperCAmelCase  ).replace("@@ "			,				""  ).strip()
      return out_string


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase			,				_UpperCamelCase = None  ):





      """simple docstring"""





      if not os.path.isdir(_UpperCAmelCase  ):
         logger.error(f'''Vocabulary path ({save_directory}) should be a directory'''  )
         return
      _lowercase			:      List[Any]			     =   os.path.join(
          _UpperCAmelCase			,				(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]  )
      _lowercase			:      Tuple			     =   os.path.join(
          _UpperCAmelCase			,				(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["merges_file"]  )

      if os.path.abspath(self.vocab_file  ) != os.path.abspath(_UpperCAmelCase  ):
         copyfile(self.vocab_file			,				_UpperCAmelCase  )

      if os.path.abspath(self.merges_file  ) != os.path.abspath(_UpperCAmelCase  ):
         copyfile(self.merges_file			,				_UpperCAmelCase  )

      return out_vocab_file, out_merge_file






   def 						_lowerCamelCase   ( self			,				_UpperCamelCase  ):





      """simple docstring"""





      if isinstance(_UpperCAmelCase			,				_UpperCAmelCase  ):
         try:
            with open(_UpperCAmelCase			,				"r"			,				encoding="utf-8"  ) as fd:
               self.add_from_file(_UpperCAmelCase  )
         except FileNotFoundError as fnfe:
            raise fnfe
         except UnicodeError:
            raise Exception(f'''Incorrect encoding detected in {f}, please rebuild the dataset'''  )
         return

      _lowercase			:      Optional[int]			     =   f.readlines()
      for lineTmp in lines:
         _lowercase			:      int			     =   lineTmp.strip()
         _lowercase			:      Any			     =   line.rfind(" "  )
         if idx == -1:
            raise ValueError("Incorrect dictionary format, expected \'<token> <cnt>\'"  )
         _lowercase			:      Tuple			     =   line[:idx]
         _lowercase			:      int			     =   len(self.encoder  )







"""simple docstring"""






def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase )  ->  int:
   if n == 1 or not isinstance(__UpperCAmelCase       ,    __UpperCAmelCase ):
      return 0
   elif n == 2:
      return 1
   else:
      lowercase__:   List[Any]					=      [0, 1]
      for i in range(2       ,    n + 1 ):
         sequence.append(sequence[i - 1] + sequence[i - 2] )

      return sequence[n]



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase )  ->  int:
   lowercase__:   Union[str, Any]					=      0
   lowercase__:   List[Any]					=      2

   while digits < n:
      index += 1
      lowercase__:   Dict					=      len(str(fibonacci(__UpperCAmelCase ) ) )

   return index



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase = 1_0_0_0 )  ->  int:
   return fibonacci_digits_index(__UpperCAmelCase )


if __name__ == "__main__":
       print(solution(int(str(input()).strip())))
