





import bza
import gzip
import lzma
import os
import shutil
import struct
import tarfile
import warnings
import zipfile
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict, List, Optional, Type, Union

from .. import config
from .filelock import FileLock
from .logging import get_logger


__lowerCAmelCase :List[Any]     =    get_logger(__name__)






class        _a:







		def __init__(    self ,						__snake_case = None				)      ->      Any:


							'''simple docstring'''

							_snake_case       :					str				       =   (
							    os.path.join(__snake_case ,						config.EXTRACTED_DATASETS_DIR				) if cache_dir else config.EXTRACTED_DATASETS_PATH
							)
							_snake_case       :					Any				       =   Extractor







		def        lowercase       (    self ,						__snake_case				)      ->      str:


							'''simple docstring'''

							from .file_utils import hash_url_to_filename

							# Path where we extract compressed archives
							# We extract in the cache dir, and get the extracted path name by hashing the original path"
							_snake_case       :					Union[str, Any]				       =   os.path.abspath(__snake_case				)
							return os.path.join(self.extract_dir ,						hash_url_to_filename(__snake_case				)				)







		def        lowercase       (    self ,						__snake_case ,						__snake_case				)      ->      bool:


							'''simple docstring'''

							return force_extract or (
							    not os.path.isfile(__snake_case				) and not (os.path.isdir(__snake_case				) and os.listdir(__snake_case				))
							)







		def        lowercase       (    self ,						__snake_case ,						__snake_case = False				)      ->      str:


							'''simple docstring'''

							_snake_case       :					Optional[int]				       =   self.extractor.infer_extractor_format(__snake_case				)
							if not extractor_format:
												return input_path
							_snake_case       :					Optional[int]				       =   self._get_output_path(__snake_case				)
							if self._do_extract(__snake_case ,						__snake_case				):
												self.extractor.extract(__snake_case ,						__snake_case ,						__snake_case				)
							return output_path






class        _a(    __A    ):







		@classmethod
		@abstractmethod
		def        lowercase       (    cls ,						__snake_case ,						**__snake_case				)      ->      bool:


							'''simple docstring'''

							...







		@staticmethod
		@abstractmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							...






class        _a(    __A	,   __A    ):
		lowerCamelCase__     :List[bytes]   				=		[]







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      Union[str, Any]:


							'''simple docstring'''

							with open(__snake_case ,						"rb"				) as f:
												return f.read(__snake_case				)







		@classmethod
		def        lowercase       (    cls ,						__snake_case ,						__snake_case = b""				)      ->      bool:


							'''simple docstring'''

							if not magic_number:
												_snake_case       :					str				       =   max(len(__snake_case				) for cls_magic_number in cls.magic_numbers				)
												try:
																	_snake_case       :					str				       =   cls.read_magic_number(__snake_case ,						__snake_case				)
												except OSError:
																	return False
							return any(magic_number.startswith(__snake_case				) for cls_magic_number in cls.magic_numbers				)






class        _a(    __A    ):







		@classmethod
		def        lowercase       (    cls ,						__snake_case ,						**__snake_case				)      ->      bool:


							'''simple docstring'''

							return tarfile.is_tarfile(__snake_case				)







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      Tuple:


							'''simple docstring'''

							def resolved(__snake_case				) -> str:
												return os.path.realpath(os.path.abspath(__snake_case				)				)

							def badpath(__snake_case ,						__snake_case				) -> bool:
												# joinpath will ignore base if path is absolute
												return not resolved(os.path.join(__snake_case ,						__snake_case				)				).startswith(__snake_case				)

							def badlink(__snake_case ,						__snake_case				) -> bool:
												# Links are interpreted relative to the directory containing the link
												_snake_case       :					str				       =   resolved(os.path.join(__snake_case ,						os.path.dirname(info.name				)				)				)
												return badpath(info.linkname ,						base=__snake_case				)

							_snake_case       :					Dict				       =   resolved(__snake_case				)

							for finfo in members:
												if badpath(finfo.name ,						__snake_case				):
																	logger.error(f"""Extraction of {finfo.name} is blocked (illegal path)"""				)
												elif finfo.issym() and badlink(__snake_case ,						__snake_case				):
																	logger.error(f"""Extraction of {finfo.name} is blocked: Symlink to {finfo.linkname}"""				)
												elif finfo.islnk() and badlink(__snake_case ,						__snake_case				):
																	logger.error(f"""Extraction of {finfo.name} is blocked: Hard link to {finfo.linkname}"""				)
												else:
																	yield finfo







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							os.makedirs(__snake_case ,						exist_ok=__snake_case				)
							_snake_case       :					List[Any]				       =   tarfile.open(__snake_case				)
							tar_file.extractall(__snake_case ,						members=TarExtractor.safemembers(__snake_case ,						__snake_case				)				)
							tar_file.close()






class        _a(    __A    ):
		lowerCamelCase__     :Any   				=		[B'\x1F\x8B']







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							with gzip.open(__snake_case ,						"rb"				) as gzip_file:
												with open(__snake_case ,						"wb"				) as extracted_file:
																	shutil.copyfileobj(__snake_case ,						__snake_case				)






class        _a(    __A    ):
		lowerCamelCase__     :Dict   				=		[
		    B'PK\x03\x04',
		    B'PK\x05\x06',  # empty archive
		    B'PK\x07\x08',  # spanned archive
		]







		@classmethod
		def        lowercase       (    cls ,						__snake_case ,						__snake_case = b""				)      ->      bool:


							'''simple docstring'''

							if super().is_extractable(__snake_case ,						magic_number=__snake_case				):
												return True
							try:
												# Alternative version of zipfile.is_zipfile that has less false positives, but misses executable zip archives.
												# From: https://github.com/python/cpython/pull/5053
												from zipfile import (
												    _CD_SIGNATURE,
												    _ECD_DISK_NUMBER,
												    _ECD_DISK_START,
												    _ECD_ENTRIES_TOTAL,
												    _ECD_OFFSET,
												    _ECD_SIZE,
												    _EndRecData,
												    sizeCentralDir,
												    stringCentralDir,
												    structCentralDir,
												)

												with open(__snake_case ,						"rb"				) as fp:
																	_snake_case       :					Union[str, Any]				       =   _EndRecData(__snake_case				)
																	if endrec:
																						if endrec[_ECD_ENTRIES_TOTAL] == 0 and endrec[_ECD_SIZE] == 0 and endrec[_ECD_OFFSET] == 0:
																											return True  # Empty zipfiles are still zipfiles
																						elif endrec[_ECD_DISK_NUMBER] == endrec[_ECD_DISK_START]:
																											fp.seek(endrec[_ECD_OFFSET]				)  # Central directory is on the same disk
																											if fp.tell() == endrec[_ECD_OFFSET] and endrec[_ECD_SIZE] >= sizeCentralDir:
																																_snake_case       :					List[str]				       =   fp.read(__snake_case				)  # CD is where we expect it to be
																																if len(__snake_case				) == sizeCentralDir:
																																					_snake_case       :					Optional[int]				       =   struct.unpack(__snake_case ,						__snake_case				)  # CD is the right size
																																					if centdir[_CD_SIGNATURE] == stringCentralDir:
																																										return True  # First central directory entry  has correct magic number
												return False
							except Exception:  # catch all errors in case future python versions change the zipfile internals
												return False







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							os.makedirs(__snake_case ,						exist_ok=__snake_case				)
							with zipfile.ZipFile(__snake_case ,						"r"				) as zip_file:
												zip_file.extractall(__snake_case				)
												zip_file.close()






class        _a(    __A    ):
		lowerCamelCase__     :str   				=		[B'\xFD\x37\x7A\x58\x5A\x00']







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							with lzma.open(__snake_case				) as compressed_file:
												with open(__snake_case ,						"wb"				) as extracted_file:
																	shutil.copyfileobj(__snake_case ,						__snake_case				)






class        _a(    __A    ):
		lowerCamelCase__     :List[Any]   				=		[B'Rar!\x1a\x07\x00', B'Rar!\x1a\x07\x01\x00']  # RAR_ID  # RAR5_ID







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							if not config.RARFILE_AVAILABLE:
												raise ImportError("Please pip install rarfile"				)
							import rarfile

							os.makedirs(__snake_case ,						exist_ok=__snake_case				)
							_snake_case       :					List[str]				       =   rarfile.RarFile(__snake_case				)
							rf.extractall(__snake_case				)
							rf.close()






class        _a(    __A    ):
		lowerCamelCase__     :Any   				=		[B'\x28\xb5\x2F\xFD']







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							if not config.ZSTANDARD_AVAILABLE:
												raise ImportError("Please pip install zstandard"				)
							import zstandard as zstd

							_snake_case       :					Dict				       =   zstd.ZstdDecompressor()
							with open(__snake_case ,						"rb"				) as ifh, open(__snake_case ,						"wb"				) as ofh:
												dctx.copy_stream(__snake_case ,						__snake_case				)






class        _a(    __A    ):
		lowerCamelCase__     :Tuple   				=		[B'\x42\x5A\x68']







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							with bza.open(__snake_case ,						"rb"				) as compressed_file:
												with open(__snake_case ,						"wb"				) as extracted_file:
																	shutil.copyfileobj(__snake_case ,						__snake_case				)






class        _a(    __A    ):
		lowerCamelCase__     :Tuple   				=		[B'\x37\x7A\xBC\xAF\x27\x1C']







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							if not config.PY7ZR_AVAILABLE:
												raise ImportError("Please pip install py7zr"				)
							import pyazr

							os.makedirs(__snake_case ,						exist_ok=__snake_case				)
							with pyazr.SevenZipFile(__snake_case ,						"r"				) as archive:
												archive.extractall(__snake_case				)






class        _a(    __A    ):
		lowerCamelCase__     :Tuple   				=		[B'\x04\x22\x4D\x18']







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      None:


							'''simple docstring'''

							if not config.LZ4_AVAILABLE:
												raise ImportError("Please pip install lz4"				)
							import lza.frame

							with lza.frame.open(__snake_case ,						"rb"				) as compressed_file:
												with open(__snake_case ,						"wb"				) as extracted_file:
																	shutil.copyfileobj(__snake_case ,						__snake_case				)






class        _a:
		#  Put zip file to the last, b/c it is possible wrongly detected as zip (I guess it means: as tar or gzip)
		lowerCamelCase__     :Dict[str, Type[BaseExtractor]]   				=		{
		    "tar": TarExtractor,
		    "gzip": GzipExtractor,
		    "zip": ZipExtractor,
		    "xz": XzExtractor,
		    "rar": RarExtractor,
		    "zstd": ZstdExtractor,
		    "bz2": BzipaExtractor,
		    "7z": SevenZipExtractor,  # <Added version="2.4.0"/>
		    "lz4": LzaExtractor,  # <Added version="2.4.0"/>
		}







		@classmethod
		def        lowercase       (    cls				)      ->      Optional[Any]:


							'''simple docstring'''

							return max(
							    len(__snake_case				)
							    for extractor in cls.extractors.values()
							    if issubclass(__snake_case ,						__snake_case				)
							    for extractor_magic_number in extractor.magic_numbers				)







		@staticmethod
		def        lowercase       (    __snake_case ,						__snake_case				)      ->      Any:


							'''simple docstring'''

							try:
												return MagicNumberBaseExtractor.read_magic_number(__snake_case ,						magic_number_length=__snake_case				)
							except OSError:
												return b""







		@classmethod
		def        lowercase       (    cls ,						__snake_case ,						__snake_case = False				)      ->      bool:


							'''simple docstring'''

							warnings.warn(
							    "Method 'is_extractable' was deprecated in version 2.4.0 and will be removed in 3.0.0. "
							    "Use 'infer_extractor_format' instead." ,						category=__snake_case ,						)
							_snake_case       :					Union[str, Any]				       =   cls.infer_extractor_format(__snake_case				)
							if extractor_format:
												return True if not return_extractor else (True, cls.extractors[extractor_format])
							return False if not return_extractor else (False, None)







		@classmethod
		def        lowercase       (    cls ,						__snake_case				)      ->      str:  # <Added version="2.4.0"/>


							'''simple docstring'''

							_snake_case       :					Union[str, Any]				       =   cls._get_magic_number_max_length()
							_snake_case       :					Dict				       =   cls._read_magic_number(__snake_case ,						__snake_case				)
							for extractor_format, extractor in cls.extractors.items():
												if extractor.is_extractable(__snake_case ,						magic_number=__snake_case				):
																	return extractor_format







		@classmethod
		def        lowercase       (    cls ,						__snake_case ,						__snake_case ,						__snake_case = None ,						__snake_case = "deprecated" ,						)      ->      None:


							'''simple docstring'''

							os.makedirs(os.path.dirname(__snake_case				) ,						exist_ok=__snake_case				)
							# Prevent parallel extractions
							_snake_case       :					Optional[int]				       =   str(Path(__snake_case				).with_suffix(".lock"				)				)
							with FileLock(__snake_case				):
												shutil.rmtree(__snake_case ,						ignore_errors=__snake_case				)
												if extractor_format or extractor != "deprecated":
																	if extractor != "deprecated" or not isinstance(__snake_case ,						__snake_case				):  # passed as positional arg
																						warnings.warn(
																						    "Parameter 'extractor' was deprecated in version 2.4.0 and will be removed in 3.0.0. "
																						    "Use 'extractor_format' instead." ,						category=__snake_case ,						)
																						_snake_case       :					Any				       =   extractor if extractor != "deprecated" else extractor_format
																	else:
																						_snake_case       :					Optional[Any]				       =   cls.extractors[extractor_format]
																	return extractor.extract(__snake_case ,						__snake_case				)
												else:
																	warnings.warn(
																	    "Parameter 'extractor_format' was made required in version 2.4.0 and not passing it will raise an "
																	    "exception in 3.0.0." ,						category=__snake_case ,						)
																	for extractor in cls.extractors.values():
																						if extractor.is_extractable(__snake_case				):
																											return extractor.extract(__snake_case ,						__snake_case				)






def    A				(							UpperCAmelCase				):
					if n == 1 or not isinstance(UpperCAmelCase  ,  UpperCAmelCase				):
										return 0
					elif n == 2:
										return 1
					else:
										_snake_case       :					List[Any]				       =   [0, 1]
										for i in range(2  ,  n + 1				):
															sequence.append(sequence[i - 1] + sequence[i - 2]				)

										return sequence[n]







def    A				(							UpperCAmelCase				):
					_snake_case       :					Tuple				       =   0
					_snake_case       :					Optional[Any]				       =   2

					while digits < n:
										index += 1
										_snake_case       :					str				       =   len(str(fibonacci(UpperCAmelCase				)				)				)

					return index







def    A				(							UpperCAmelCase = 1_000				):
					return fibonacci_digits_index(UpperCAmelCase				)


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