
"""simple docstring"""




from typing import Optional, Union

import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_mobilenet_va import MobileNetVaConfig


a		:       int     						=       logging.get_logger(__name__)


# General docstring
a		:       List[str]     						=       'MobileNetV1Config'

# Base docstring
a		:       Optional[Any]     						=       'google/mobilenet_v1_1.0_224'
a		:       Optional[int]     						=       [1, 10_24, 7, 7]

# Image classification docstring
a		:       Tuple     						=       'google/mobilenet_v1_1.0_224'
a		:       Optional[Any]     						=       'tabby, tabby cat'


a		:       str     						=       [
    'google/mobilenet_v1_1.0_224',
    'google/mobilenet_v1_0.75_192',
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
]



def     __magic_name__		(					UpperCamelCase     :		int							,		UpperCamelCase     :		List[Any]							,		UpperCamelCase     :		List[str]=None     )     ->						Optional[int]:
    a__		=			{}

    if isinstance(__UpperCAmelCase							,		__UpperCAmelCase     ):
        a__		=			model.mobilenet_va
    else:
        a__		=			model

    a__		=			'MobilenetV1/Conv2d_0/'
    a__		=			backbone.conv_stem.convolution.weight
    a__		=			backbone.conv_stem.normalization.bias
    a__		=			backbone.conv_stem.normalization.weight
    a__		=			backbone.conv_stem.normalization.running_mean
    a__		=			backbone.conv_stem.normalization.running_var

    for i in range(13     ):
        a__		=			i + 1
        a__		=			i * 2

        a__		=			backbone.layer[pt_index]
        a__		=			f'MobilenetV1/Conv2d_{tf_index}_depthwise/'
        a__		=			pointer.convolution.weight
        a__		=			pointer.normalization.bias
        a__		=			pointer.normalization.weight
        a__		=			pointer.normalization.running_mean
        a__		=			pointer.normalization.running_var

        a__		=			backbone.layer[pt_index + 1]
        a__		=			f'MobilenetV1/Conv2d_{tf_index}_pointwise/'
        a__		=			pointer.convolution.weight
        a__		=			pointer.normalization.bias
        a__		=			pointer.normalization.weight
        a__		=			pointer.normalization.running_mean
        a__		=			pointer.normalization.running_var

    if isinstance(__UpperCAmelCase							,		__UpperCAmelCase     ):
        a__		=			'MobilenetV1/Logits/Conv2d_1c_1x1/'
        a__		=			model.classifier.weight
        a__		=			model.classifier.bias

    return tf_to_pt_map



def     __magic_name__		(					UpperCamelCase     :		Dict							,		UpperCamelCase     :		str							,		UpperCamelCase     :		int     )     ->						Any:

    try:
        import numpy as np
        import tensorflow as tf
    except ImportError:
        logger.error(
            'Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see '
            'https://www.tensorflow.org/install/ for installation instructions.'     )
        raise

    # Load weights from TF model
    a__		=			tf.train.list_variables(__UpperCAmelCase     )
    a__		=			{}
    for name, shape in init_vars:
        logger.info(f'Loading TF weight {name} with shape {shape}'     )
        a__		=			tf.train.load_variable(__UpperCAmelCase							,		__UpperCAmelCase     )
        a__		=			array

    # Build TF to PyTorch weights loading map
    a__		=			_build_tf_to_pytorch_map(__UpperCAmelCase							,		__UpperCAmelCase							,		__UpperCAmelCase     )

    for name, pointer in tf_to_pt_map.items():
        logger.info(f'Importing {name}'     )
        if name not in tf_weights:
            logger.info(f'{name} not in tf pre-trained weights, skipping'     )
            continue

        a__		=			tf_weights[name]

        if "depthwise_weights" in name:
            logger.info('Transposing depthwise'     )
            a__		=			np.transpose(__UpperCAmelCase							,		(2, 3, 0, 1)     )
        elif "weights" in name:
            logger.info('Transposing'     )
            if len(pointer.shape     ) == 2:  # copying into linear layer
                a__		=			array.squeeze().transpose()
            else:
                a__		=			np.transpose(__UpperCAmelCase							,		(3, 2, 0, 1)     )

        if pointer.shape != array.shape:
            raise ValueError(f'Pointer shape {pointer.shape} and array shape {array.shape} mismatched'     )

        logger.info(f'Initialize PyTorch weight {name} {array.shape}'     )
        a__		=			torch.from_numpy(__UpperCAmelCase     )

        tf_weights.pop(__UpperCAmelCase							,		__UpperCAmelCase     )
        tf_weights.pop(name + '/RMSProp'							,		__UpperCAmelCase     )
        tf_weights.pop(name + '/RMSProp_1'							,		__UpperCAmelCase     )
        tf_weights.pop(name + '/ExponentialMovingAverage'							,		__UpperCAmelCase     )

    logger.info(f'Weights not copied to PyTorch model: {", ".join(tf_weights.keys()     )}'     )
    return model



def     __magic_name__		(					UpperCamelCase     :		str							,		UpperCamelCase     :		Optional[Any]     )     ->						torch.Tensor:
    a__	,     a__		=			features.shape[-2:]
    a__	,     a__		=			conv_layer.stride
    a__	,     a__		=			conv_layer.kernel_size

    if in_height % stride_height == 0:
        a__		=			max(kernel_height - stride_height							,		0     )
    else:
        a__		=			max(kernel_height - (in_height % stride_height)							,		0     )

    if in_width % stride_width == 0:
        a__		=			max(kernel_width - stride_width							,		0     )
    else:
        a__		=			max(kernel_width - (in_width % stride_width)							,		0     )

    a__		=			pad_along_width // 2
    a__		=			pad_along_width - pad_left
    a__		=			pad_along_height // 2
    a__		=			pad_along_height - pad_top

    a__		=			(pad_left, pad_right, pad_top, pad_bottom)
    return nn.functional.pad(__UpperCAmelCase							,		__UpperCAmelCase							,		'constant'							,		0.0     )







class     lowercase(nn.Module       ):



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = 1     ,				__SCREAMING_SNAKE_CASE = 1     ,				__SCREAMING_SNAKE_CASE = False     ,				__SCREAMING_SNAKE_CASE = True     ,				__SCREAMING_SNAKE_CASE = True     ,				)		->     List[Any]:







         """simple docstring"""



         super().__init__()
         a__		=			config

         if in_channels % groups != 0:
             raise ValueError(f'Input channels ({in_channels}) are not divisible by {groups} groups.'   )
         if out_channels % groups != 0:
             raise ValueError(f'Output channels ({out_channels}) are not divisible by {groups} groups.'   )

         a__		=			0 if config.tf_padding else int((kernel_size - 1) / 2   )

         a__		=			nn.Convad(
             in_channels=lowercase_     ,				out_channels=lowercase_     ,				kernel_size=lowercase_     ,				stride=lowercase_     ,				padding=lowercase_     ,				groups=lowercase_     ,				bias=lowercase_     ,				padding_mode='zeros'     ,				)

         if use_normalization:
             a__		=			nn.BatchNormad(
                 num_features=lowercase_     ,				eps=config.layer_norm_eps     ,				momentum=0.99_97     ,				affine=lowercase_     ,				track_running_stats=lowercase_     ,				)
         else:
             a__		=			None

         if use_activation:
             if isinstance(lowercase_     ,				lowercase_   ):
                 a__		=			ACTaFN[use_activation]
             elif isinstance(config.hidden_act     ,				lowercase_   ):
                 a__		=			ACTaFN[config.hidden_act]
             else:
                 a__		=			config.hidden_act
         else:
             a__		=			None




     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



         if self.config.tf_padding:
             a__		=			apply_tf_padding(lowercase_     ,				self.convolution   )
         a__		=			self.convolution(lowercase_   )
         if self.normalization is not None:
             a__		=			self.normalization(lowercase_   )
         if self.activation is not None:
             a__		=			self.activation(lowercase_   )
         return features







class     lowercase(_lowerCamelCase       ):
     __snake_case:	Dict						=     MobileNetVaConfig
     __snake_case:	str						=     load_tf_weights_in_mobilenet_va
     __snake_case:	int						=     'mobilenet_v1'
     __snake_case:	str						=     'pixel_values'
     __snake_case:	List[Any]						=     False



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     int:







         """simple docstring"""



         if isinstance(lowercase_     ,				(nn.Linear, nn.Convad)   ):
             module.weight.data.normal_(mean=0.0     ,				std=self.config.initializer_range   )
             if module.bias is not None:
                 module.bias.data.zero_()
         elif isinstance(lowercase_     ,				nn.BatchNormad   ):
             module.bias.data.zero_()
             module.weight.data.fill_(1.0   )




a		:       Tuple     						=       r'\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`MobileNetV1Config`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'

a		:       Dict     						=       r'\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`MobileNetV1ImageProcessor.__call__`] for details.\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.\n'







@add_start_docstrings(
    'The bare MobileNetV1 model outputting raw hidden-states without any specific head on top.'    ,						_lowerCamelCase    ,						)
class     lowercase(_lowerCamelCase       ):



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE     ,				__SCREAMING_SNAKE_CASE = True   )		->     int:







         """simple docstring"""



         super().__init__(lowercase_   )
         a__		=			config

         a__		=			3_2
         a__		=			max(int(depth * config.depth_multiplier   )     ,				config.min_depth   )

         a__		=			MobileNetVaConvLayer(
             lowercase_     ,				in_channels=config.num_channels     ,				out_channels=lowercase_     ,				kernel_size=3     ,				stride=2     ,				)

         a__		=			[1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1]

         a__		=			nn.ModuleList()
         for i in range(1_3   ):
             a__		=			out_channels

             if strides[i] == 2 or i == 0:
                 depth *= 2
                 a__		=			max(int(depth * config.depth_multiplier   )     ,				config.min_depth   )

             self.layer.append(
                 MobileNetVaConvLayer(
                     lowercase_     ,				in_channels=lowercase_     ,				out_channels=lowercase_     ,				kernel_size=3     ,				stride=strides[i]     ,				groups=lowercase_     ,				)   )

             self.layer.append(
                 MobileNetVaConvLayer(
                     lowercase_     ,				in_channels=lowercase_     ,				out_channels=lowercase_     ,				kernel_size=1     ,				)   )

         a__		=			nn.AdaptiveAvgPoolad((1, 1)   ) if add_pooling_layer else None

         # Initialize weights and apply final processing
         self.post_init()



     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE   )		->     str:







         """simple docstring"""



         raise NotImplementedError




     @add_start_docstrings_to_model_forward(lowercase_   )
     @add_code_sample_docstrings(
         checkpoint=_CHECKPOINT_FOR_DOC     ,				output_type=lowercase_     ,				config_class=_CONFIG_FOR_DOC     ,				modality='vision'     ,				expected_output=_EXPECTED_OUTPUT_SHAPE     ,				)
     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				)		->     List[str]:







         """simple docstring"""



         a__		=			(
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         a__		=			return_dict if return_dict is not None else self.config.use_return_dict

         if pixel_values is None:
             raise ValueError('You have to specify pixel_values'   )

         a__		=			self.conv_stem(lowercase_   )

         a__		=			() if output_hidden_states else None

         for i, layer_module in enumerate(self.layer   ):
             a__		=			layer_module(lowercase_   )

             if output_hidden_states:
                 a__		=			all_hidden_states + (hidden_states,)

         a__		=			hidden_states

         if self.pooler is not None:
             a__		=			torch.flatten(self.pooler(lowercase_   )     ,				start_dim=1   )
         else:
             a__		=			None

         if not return_dict:
             return tuple(v for v in [last_hidden_state, pooled_output, all_hidden_states] if v is not None   )

         return BaseModelOutputWithPoolingAndNoAttention(
             last_hidden_state=lowercase_     ,				pooler_output=lowercase_     ,				hidden_states=lowercase_     ,				)







@add_start_docstrings(
    '\n    MobileNetV1 model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    '    ,						_lowerCamelCase    ,						)
class     lowercase(_lowerCamelCase       ):



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE   )		->     Tuple:







         """simple docstring"""



         super().__init__(lowercase_   )

         a__		=			config.num_labels
         a__		=			MobileNetVaModel(lowercase_   )

         a__		=			self.mobilenet_va.layer[-1].convolution.out_channels

         # Classifier head
         a__		=			nn.Dropout(config.classifier_dropout_prob     ,				inplace=lowercase_   )
         a__		=			nn.Linear(lowercase_     ,				config.num_labels   ) if config.num_labels > 0 else nn.Identity()

         # Initialize weights and apply final processing
         self.post_init()




     @add_start_docstrings_to_model_forward(lowercase_   )
     @add_code_sample_docstrings(
         checkpoint=_IMAGE_CLASS_CHECKPOINT     ,				output_type=lowercase_     ,				config_class=_CONFIG_FOR_DOC     ,				expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT     ,				)
     def 			lowercase__  (							self     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				__SCREAMING_SNAKE_CASE = None     ,				)		->     List[Any]:







         """simple docstring"""



         a__		=			return_dict if return_dict is not None else self.config.use_return_dict

         a__		=			self.mobilenet_va(lowercase_     ,				output_hidden_states=lowercase_     ,				return_dict=lowercase_   )

         a__		=			outputs.pooler_output if return_dict else outputs[1]

         a__		=			self.classifier(self.dropout(lowercase_   )   )

         a__		=			None
         if labels is not None:
             if self.config.problem_type is None:
                 if self.num_labels == 1:
                     a__		=			'regression'
                 elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
                     a__		=			'single_label_classification'
                 else:
                     a__		=			'multi_label_classification'

             if self.config.problem_type == "regression":
                 a__		=			MSELoss()
                 if self.num_labels == 1:
                     a__		=			loss_fct(logits.squeeze()     ,				labels.squeeze()   )
                 else:
                     a__		=			loss_fct(lowercase_     ,				lowercase_   )
             elif self.config.problem_type == "single_label_classification":
                 a__		=			CrossEntropyLoss()
                 a__		=			loss_fct(logits.view(-1     ,				self.num_labels   )     ,				labels.view(-1   )   )
             elif self.config.problem_type == "multi_label_classification":
                 a__		=			BCEWithLogitsLoss()
                 a__		=			loss_fct(lowercase_     ,				lowercase_   )

         if not return_dict:
             a__		=			(logits,) + outputs[2:]
             return ((loss,) + output) if loss is not None else output

         return ImageClassifierOutputWithNoAttention(
             loss=lowercase_     ,				logits=lowercase_     ,				hidden_states=outputs.hidden_states     ,				)








'''simple docstring'''

from collections.abc import Generator


def 						__magic_name__       (      )						->   Generator[int, None, None]:

					'''simple docstring'''

					snake_case_     ,snake_case_		     =							0, 1
					while True:
										snake_case_     ,snake_case_		     =							b, a + b
										yield b


def 						__magic_name__       (      __UpperCAmelCase = 1000      )						->   int:

					'''simple docstring'''

					snake_case_		     =							1
					snake_case_		     =							fibonacci_generator()
					while len(str(next(__UpperCAmelCase      )      )      ) < n:
										answer += 1
					return answer + 1


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

