

import logging
import os
import threading
import time


try:
     import warnings
except ImportError:
     _snake_case						: int											=							None

try:
     import msvcrt
except ImportError:
     _snake_case						: int											=							None

try:
     import fcntl
except ImportError:
     _snake_case						: Tuple											=							None


# Backward compatibility
# ------------------------------------------------
try:
     TimeoutError
except NameError:
     _snake_case						: List[str]											=							OSError


# Data
# ------------------------------------------------
_snake_case						: Any											=							[
    'Timeout',
    'BaseFileLock',
    'WindowsFileLock',
    'UnixFileLock',
    'SoftFileLock',
    'FileLock',
]

_snake_case						: Any											=							'3.0.12'


_snake_case						: List[Any]											=							None





def    _A							(						)   -> str:



   """simple docstring"""


   global _logger
   __SCREAMING_SNAKE_CASE       =				_logger or logging.getLogger(__name__  )
   return _logger





class __SCREAMING_SNAKE_CASE     (	__snake_case		):






    def __init__(       self,		_a )   ->					Dict:
       __SCREAMING_SNAKE_CASE       =				lock_file
       return None






    def __str__(       self )   ->					int:
       __SCREAMING_SNAKE_CASE       =				f'''The file lock \'{self.lock_file}\' could not be acquired.'''
       return temp






class __SCREAMING_SNAKE_CASE     :






    def __init__(       self,		_a )   ->					List[Any]:
       __SCREAMING_SNAKE_CASE       =				lock
       return None






    def __enter__(       self )   ->					Tuple:
       return self.lock






    def __exit__(       self,		_a,		_a,		_a )   ->					int:
       self.lock.release()
       return None






class __SCREAMING_SNAKE_CASE     :






    def __init__(       self,		_a,		_a=-1,		_a=None )   ->					Dict:
       __SCREAMING_SNAKE_CASE       =				max_filename_length if max_filename_length is not None else 2_55
       # Hash the filename if it's too long
       __SCREAMING_SNAKE_CASE       =				self.hash_filename_if_too_long(_a,		_a )
       # The path to the lock file.
       __SCREAMING_SNAKE_CASE       =				lock_file

       # The file descriptor for the *_lock_file* as it is returned by the
       # os.open() function.
       # This file lock is only NOT None, if the object currently holds the
       # lock.
       __SCREAMING_SNAKE_CASE       =				None

       # The default timeout value.
       __SCREAMING_SNAKE_CASE       =				timeout

       # We use this lock primarily for the lock counter.
       __SCREAMING_SNAKE_CASE       =				threading.Lock()

       # The lock counter is used for implementing the nested locking
       # mechanism. Whenever the lock is acquired, the counter is increased and
       # the lock is only released, when this value is 0 again.
       __SCREAMING_SNAKE_CASE       =				0
       return None






    @property
    def 						__lowerCAmelCase    (       self )   ->					List[Any]:
       return self._lock_file






    @property
    def 						__lowerCAmelCase    (       self )   ->					Any:
       return self._timeout






    @timeout.setter
    def 						__lowerCAmelCase    (       self,		_a )   ->					List[Any]:
       __SCREAMING_SNAKE_CASE       =				float(_a )
       return None






    def 						__lowerCAmelCase    (       self )   ->					List[str]:
       raise NotImplementedError()






    def 						__lowerCAmelCase    (       self )   ->					List[Any]:
       raise NotImplementedError()






    @property
    def 						__lowerCAmelCase    (       self )   ->					Optional[int]:
       return self._lock_file_fd is not None






    def 						__lowerCAmelCase    (       self,		_a=None,		_a=0.05 )   ->					Optional[Any]:






       if timeout is None:
          __SCREAMING_SNAKE_CASE       =				self.timeout

       # Increment the number right at the beginning.
       # We can still undo it, if something fails.
       with self._thread_lock:
          self._lock_counter += 1

       __SCREAMING_SNAKE_CASE       =				id(self )
       __SCREAMING_SNAKE_CASE       =				self._lock_file
       __SCREAMING_SNAKE_CASE       =				time.time()
       try:
          while True:
             with self._thread_lock:
                if not self.is_locked:
                   logger().debug(f'''Attempting to acquire lock {lock_id} on {lock_filename}''' )
                   self._acquire()

             if self.is_locked:
                logger().debug(f'''Lock {lock_id} acquired on {lock_filename}''' )
                break
             elif timeout >= 0 and time.time() - start_time > timeout:
                logger().debug(f'''Timeout on acquiring lock {lock_id} on {lock_filename}''' )
                raise Timeout(self._lock_file )
             else:
                logger().debug(
                    f'''Lock {lock_id} not acquired on {lock_filename}, waiting {poll_intervall} seconds ...''' )
                time.sleep(_a )
       except:  # noqa
          # Something did go wrong, so decrement the counter.
          with self._thread_lock:
             __SCREAMING_SNAKE_CASE       =				max(0,		self._lock_counter - 1 )

          raise
       return _Acquire_ReturnProxy(lock=self )






    def 						__lowerCAmelCase    (       self,		_a=False )   ->					Optional[Any]:






       with self._thread_lock:
          if self.is_locked:
             self._lock_counter -= 1

             if self._lock_counter == 0 or force:
                __SCREAMING_SNAKE_CASE       =				id(self )
                __SCREAMING_SNAKE_CASE       =				self._lock_file

                logger().debug(f'''Attempting to release lock {lock_id} on {lock_filename}''' )
                self._release()
                __SCREAMING_SNAKE_CASE       =				0
                logger().debug(f'''Lock {lock_id} released on {lock_filename}''' )

       return None






    def __enter__(       self )   ->					Any:
       self.acquire()
       return self






    def __exit__(       self,		_a,		_a,		_a )   ->					Tuple:
       self.release()
       return None






    def __del__(       self )   ->					Dict:
       self.release(force=_a )
       return None






    def 						__lowerCAmelCase    (       self,		_a,		_a )   ->					Any:
       __SCREAMING_SNAKE_CASE       =				os.path.basename(_a )
       if len(_a ) > max_length and max_length > 0:
          __SCREAMING_SNAKE_CASE       =				os.path.dirname(_a )
          __SCREAMING_SNAKE_CASE       =				str(hash(_a ) )
          __SCREAMING_SNAKE_CASE       =				filename[: max_length - len(_a ) - 8] + "..." + hashed_filename + ".lock"
          return os.path.join(_a,		_a )
       else:
          return path






class __SCREAMING_SNAKE_CASE     (	__snake_case		):






    def __init__(       self,		_a,		_a=-1,		_a=None )   ->					Optional[int]:
       from .file_utils import relative_to_absolute_path

       super().__init__(_a,		timeout=_a,		max_filename_length=_a )
       __SCREAMING_SNAKE_CASE       =				"\\\\?\\" + relative_to_absolute_path(self.lock_file )






    def 						__lowerCAmelCase    (       self )   ->					Optional[Any]:
       __SCREAMING_SNAKE_CASE       =				os.O_RDWR | os.O_CREAT | os.O_TRUNC

       try:
          __SCREAMING_SNAKE_CASE       =				os.open(self._lock_file,		_a )
       except OSError:
          pass
       else:
          try:
             msvcrt.locking(_a,		msvcrt.LK_NBLCK,		1 )
          except OSError:
             os.close(_a )
          else:
             __SCREAMING_SNAKE_CASE       =				fd
       return None






    def 						__lowerCAmelCase    (       self )   ->					Dict:
       __SCREAMING_SNAKE_CASE       =				self._lock_file_fd
       __SCREAMING_SNAKE_CASE       =				None
       msvcrt.locking(_a,		msvcrt.LK_UNLCK,		1 )
       os.close(_a )

       try:
          os.remove(self._lock_file )
       # Probably another instance of the application
       # that acquired the file lock.
       except OSError:
          pass
       return None






class __SCREAMING_SNAKE_CASE     (	__snake_case		):






    def __init__(       self,		_a,		_a=-1,		_a=None )   ->					Optional[int]:
       __SCREAMING_SNAKE_CASE       =				os.statvfs(os.path.dirname(_a ) ).f_namemax
       super().__init__(_a,		timeout=_a,		max_filename_length=_a )






    def 						__lowerCAmelCase    (       self )   ->					Tuple:
       __SCREAMING_SNAKE_CASE       =				os.O_RDWR | os.O_CREAT | os.O_TRUNC
       __SCREAMING_SNAKE_CASE       =				os.open(self._lock_file,		_a )

       try:
          fcntl.flock(_a,		fcntl.LOCK_EX | fcntl.LOCK_NB )
       except OSError:
          os.close(_a )
       else:
          __SCREAMING_SNAKE_CASE       =				fd
       return None






    def 						__lowerCAmelCase    (       self )   ->					Dict:
       __SCREAMING_SNAKE_CASE       =				self._lock_file_fd
       __SCREAMING_SNAKE_CASE       =				None
       fcntl.flock(_a,		fcntl.LOCK_UN )
       os.close(_a )
       return None






class __SCREAMING_SNAKE_CASE     (	__snake_case		):






    def 						__lowerCAmelCase    (       self )   ->					int:
       __SCREAMING_SNAKE_CASE       =				os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
       try:
          __SCREAMING_SNAKE_CASE       =				os.open(self._lock_file,		_a )
       except OSError:
          pass
       else:
          __SCREAMING_SNAKE_CASE       =				fd
       return None






    def 						__lowerCAmelCase    (       self )   ->					Dict:
       os.close(self._lock_file_fd )
       __SCREAMING_SNAKE_CASE       =				None

       try:
          os.remove(self._lock_file )
       # The file is already deleted and that's what we want.
       except OSError:
          pass
       return None






_snake_case						: str											=							None

if msvcrt:
     _snake_case						: Optional[int]											=							WindowsFileLock
elif fcntl:
     _snake_case						: Tuple											=							UnixFileLock
else:
     _snake_case						: List[Any]											=							SoftFileLock

     if warnings is not None:
          warnings.warn('only soft file lock is available')





"""simple docstring"""



def      UpperCAmelCase     (       _lowercase :   int = 1_0_0_0	)						-> int:


	"""simple docstring"""




	lowerCAmelCase_							,	lowerCAmelCase_      							=			1, 1
	lowerCAmelCase_      							=			[]
	for i in range(1			,   n + 1	):
		lowerCAmelCase_      							=			prev_numerator + 2 * prev_denominator
		lowerCAmelCase_      							=			prev_numerator + prev_denominator
		if len(str(_lowercase	)	) > len(str(_lowercase	)	):
			result.append(_lowercase	)
		lowerCAmelCase_      							=			numerator
		lowerCAmelCase_      							=			denominator

	return len(_lowercase	)


if __name__ == "__main__":
		print(f"""{solution() = }""")