






import functools
import gc
import inspect

import torch

from .imports import is_npu_available, is_xpu_available





def  _lowerCamelCase						(						*__lowerCamelCase       ) ->			Optional[int]:

     '''simple docstring'''
     if not isinstance(__lowerCamelCase ,							__lowerCamelCase       ):
          UpperCAmelCase__      :  Any				      =			list(__lowerCamelCase       )
     for i in range(len(__lowerCamelCase       )       ):
          UpperCAmelCase__      :  List[str]				      =			None
     gc.collect()
     if is_xpu_available():
          torch.xpu.empty_cache()
     elif is_npu_available():
          torch.npu.empty_cache()
     else:
          torch.cuda.empty_cache()
     return objects





def  _lowerCamelCase						(						__lowerCamelCase       ) ->			bool:

     '''simple docstring'''
     UpperCAmelCase__      :  str				      =			[
         """CUDA out of memory.""",  # CUDA OOM
         """cuDNN error: CUDNN_STATUS_NOT_SUPPORTED.""",  # CUDNN SNAFU
         """DefaultCPUAllocator: can't allocate memory""",  # CPU OOM
     ]
     if isinstance(__lowerCamelCase ,							__lowerCamelCase       ) and len(exception.args       ) == 1:
          return any(err in exception.args[0] for err in _statements       )
     return False







def  _lowerCamelCase						(						__lowerCamelCase = None ,							__lowerCamelCase = 128       ) ->			Dict:

     '''simple docstring'''
     if function is None:
          return functools.partial(__lowerCamelCase ,							starting_batch_size=__lowerCamelCase       )

     UpperCAmelCase__      :  Union[str, Any]				      =			starting_batch_size

     def decorator(*__lowerCamelCase ,							**__lowerCamelCase       ):
          nonlocal batch_size
          gc.collect()
          if is_xpu_available():
               torch.xpu.empty_cache()
          elif is_npu_available():
               torch.npu.empty_cache()
          else:
               torch.cuda.empty_cache()
          UpperCAmelCase__      :  int				      =			list(inspect.signature(__lowerCamelCase       ).parameters.keys()       )
          # Guard against user error
          if len(__lowerCamelCase       ) < (len(__lowerCamelCase       ) + 1):
               UpperCAmelCase__      :  Dict				      =			""", """.join([F"{arg}={value}" for arg, value in zip(params[1:] ,							args[1:]       )]       )
               raise TypeError(
                   F"Batch size was passed into `{function.__name__}` as the first argument when called."
                   F"Remove this as the decorator already does so: `{function.__name__}({arg_str})`"       )
          while True:
               if batch_size == 0:
                    raise RuntimeError("""No executable batch size found, reached zero."""       )
               try:
                    return function(__lowerCamelCase ,							*__lowerCamelCase ,							**__lowerCamelCase       )
               except Exception as e:
                    if should_reduce_batch_size(__lowerCamelCase       ):
                         gc.collect()
                         if is_xpu_available():
                              torch.xpu.empty_cache()
                         elif is_npu_available():
                              torch.npu.empty_cache()
                         else:
                              torch.cuda.empty_cache()
                         batch_size //= 2
                    else:
                         raise

     return decorator










def 	_UpperCamelCase					(    lowerCAmelCase_ )    ->int:
   if n == 1 or not isinstance(lowerCAmelCase_	,    lowerCAmelCase_ ):
      return 0
   elif n == 2:
      return 1
   else:
      UpperCAmelCase      					=  [0, 1]
      for i in range(2	,    n + 1 ):
         sequence.append(sequence[i - 1] + sequence[i - 2] )

      return sequence[n]
def 	_UpperCamelCase					(    lowerCAmelCase_ )    ->int:
   UpperCAmelCase      					=  0
   UpperCAmelCase      					=  2

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

   return index
def 	_UpperCamelCase					(    lowerCAmelCase_ = 1_0_0_0 )    ->int:
   return fibonacci_digits_index(lowerCAmelCase_ )


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



