


import collections
import inspect
import unittest

from transformers import SwinConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch
		from torch import nn

		from transformers import SwinBackbone, SwinForImageClassification, SwinForMaskedImageModeling, SwinModel
		from transformers.models.swin.modeling_swin import SWIN_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
		from PIL import Image

		from transformers import AutoImageProcessor


class        __lowerCamelCase      :


				"""simple docstring"""







				def __init__(				self     :    List[Any]	,							lowerCamelCase_     :    Tuple	,							lowerCamelCase_     :    Union[str, Any]=13	,							lowerCamelCase_     :    int=32	,							lowerCamelCase_     :    Optional[int]=2	,							lowerCamelCase_     :    List[Any]=3	,							lowerCamelCase_     :    Optional[int]=16	,							lowerCamelCase_     :    Union[str, Any]=[1, 2, 1]	,							lowerCamelCase_     :    int=[2, 2, 4]	,							lowerCamelCase_     :    Any=2	,							lowerCamelCase_     :    Any=2.0	,							lowerCamelCase_     :    Union[str, Any]=True	,							lowerCamelCase_     :    Tuple=0.0	,							lowerCamelCase_     :    int=0.0	,							lowerCamelCase_     :    Tuple=0.1	,							lowerCamelCase_     :    str="gelu"	,							lowerCamelCase_     :    List[Any]=False	,							lowerCamelCase_     :    Dict=True	,							lowerCamelCase_     :    List[Any]=0.02	,							lowerCamelCase_     :    Optional[Any]=1e-5	,							lowerCamelCase_     :    Any=True	,							lowerCamelCase_     :    str=None	,							lowerCamelCase_     :    Any=True	,							lowerCamelCase_     :    List[str]=10	,							lowerCamelCase_     :    List[Any]=8	,							lowerCamelCase_     :    Optional[int]=["stage1", "stage2"]	,							lowerCamelCase_     :    Optional[Any]=[1, 2]	,							):
								_lowerCAmelCase  						=parent
								_lowerCAmelCase  						=batch_size
								_lowerCAmelCase  						=image_size
								_lowerCAmelCase  						=patch_size
								_lowerCAmelCase  						=num_channels
								_lowerCAmelCase  						=embed_dim
								_lowerCAmelCase  						=depths
								_lowerCAmelCase  						=num_heads
								_lowerCAmelCase  						=window_size
								_lowerCAmelCase  						=mlp_ratio
								_lowerCAmelCase  						=qkv_bias
								_lowerCAmelCase  						=hidden_dropout_prob
								_lowerCAmelCase  						=attention_probs_dropout_prob
								_lowerCAmelCase  						=drop_path_rate
								_lowerCAmelCase  						=hidden_act
								_lowerCAmelCase  						=use_absolute_embeddings
								_lowerCAmelCase  						=patch_norm
								_lowerCAmelCase  						=layer_norm_eps
								_lowerCAmelCase  						=initializer_range
								_lowerCAmelCase  						=is_training
								_lowerCAmelCase  						=scope
								_lowerCAmelCase  						=use_labels
								_lowerCAmelCase  						=type_sequence_label_size
								_lowerCAmelCase  						=encoder_stride
								_lowerCAmelCase  						=out_features
								_lowerCAmelCase  						=out_indices






				def        lowerCAmelCase__			(				self     :    Any					):
								_lowerCAmelCase  						=floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

								_lowerCAmelCase  						=None
								if self.use_labels:
												_lowerCAmelCase  						=ids_tensor([self.batch_size]	,							self.type_sequence_label_size					)

								_lowerCAmelCase  						=self.get_config()

								return config, pixel_values, labels






				def        lowerCAmelCase__			(				self     :    Any					):
								return SwinConfig(
								    image_size=self.image_size	,							patch_size=self.patch_size	,							num_channels=self.num_channels	,							embed_dim=self.embed_dim	,							depths=self.depths	,							num_heads=self.num_heads	,							window_size=self.window_size	,							mlp_ratio=self.mlp_ratio	,							qkv_bias=self.qkv_bias	,							hidden_dropout_prob=self.hidden_dropout_prob	,							attention_probs_dropout_prob=self.attention_probs_dropout_prob	,							drop_path_rate=self.drop_path_rate	,							hidden_act=self.hidden_act	,							use_absolute_embeddings=self.use_absolute_embeddings	,							path_norm=self.patch_norm	,							layer_norm_eps=self.layer_norm_eps	,							initializer_range=self.initializer_range	,							encoder_stride=self.encoder_stride	,							out_features=self.out_features	,							out_indices=self.out_indices	,							)






				def        lowerCAmelCase__			(				self     :    List[Any]	,							lowerCamelCase_     :    List[Any]	,							lowerCamelCase_     :    List[Any]	,							lowerCamelCase_     :    str					):
								_lowerCAmelCase  						=SwinModel(config=lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()
								_lowerCAmelCase  						=model(lowerCamelCase_					)

								_lowerCAmelCase  						=((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths					) - 1))
								_lowerCAmelCase  						=int(config.embed_dim * 2 ** (len(config.depths					) - 1)					)

								self.parent.assertEqual(result.last_hidden_state.shape	,							(self.batch_size, expected_seq_len, expected_dim)					)






				def        lowerCAmelCase__			(				self     :    Any	,							lowerCamelCase_     :    Any	,							lowerCamelCase_     :    str	,							lowerCamelCase_     :    Any					):
								_lowerCAmelCase  						=SwinBackbone(config=lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()
								_lowerCAmelCase  						=model(lowerCamelCase_					)

								# verify hidden states
								self.parent.assertEqual(len(result.feature_maps					)	,							len(config.out_features					)					)
								self.parent.assertListEqual(list(result.feature_maps[0].shape					)	,							[self.batch_size, model.channels[0], 16, 16]					)

								# verify channels
								self.parent.assertEqual(len(model.channels					)	,							len(config.out_features					)					)

								# verify backbone works with out_features=None
								_lowerCAmelCase  						=None
								_lowerCAmelCase  						=SwinBackbone(config=lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()
								_lowerCAmelCase  						=model(lowerCamelCase_					)

								# verify feature maps
								self.parent.assertEqual(len(result.feature_maps					)	,							1					)
								self.parent.assertListEqual(list(result.feature_maps[0].shape					)	,							[self.batch_size, model.channels[-1], 4, 4]					)

								# verify channels
								self.parent.assertEqual(len(model.channels					)	,							1					)






				def        lowerCAmelCase__			(				self     :    Optional[int]	,							lowerCamelCase_     :    int	,							lowerCamelCase_     :    Optional[int]	,							lowerCamelCase_     :    Tuple					):
								_lowerCAmelCase  						=SwinForMaskedImageModeling(config=lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()
								_lowerCAmelCase  						=model(lowerCamelCase_					)
								self.parent.assertEqual(
								    result.logits.shape	,							(self.batch_size, self.num_channels, self.image_size, self.image_size)					)

								# test greyscale images
								_lowerCAmelCase  						=1
								_lowerCAmelCase  						=SwinForMaskedImageModeling(lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()

								_lowerCAmelCase  						=floats_tensor([self.batch_size, 1, self.image_size, self.image_size]					)
								_lowerCAmelCase  						=model(lowerCamelCase_					)
								self.parent.assertEqual(result.logits.shape	,							(self.batch_size, 1, self.image_size, self.image_size)					)






				def        lowerCAmelCase__			(				self     :    List[Any]	,							lowerCamelCase_     :    Any	,							lowerCamelCase_     :    Union[str, Any]	,							lowerCamelCase_     :    Union[str, Any]					):
								_lowerCAmelCase  						=self.type_sequence_label_size
								_lowerCAmelCase  						=SwinForImageClassification(lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()
								_lowerCAmelCase  						=model(lowerCamelCase_	,							labels=lowerCamelCase_					)
								self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.type_sequence_label_size)					)

								# test greyscale images
								_lowerCAmelCase  						=1
								_lowerCAmelCase  						=SwinForImageClassification(lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()

								_lowerCAmelCase  						=floats_tensor([self.batch_size, 1, self.image_size, self.image_size]					)
								_lowerCAmelCase  						=model(lowerCamelCase_					)
								self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.type_sequence_label_size)					)






				def        lowerCAmelCase__			(				self     :    List[Any]					):
								_lowerCAmelCase  						=self.prepare_config_and_inputs()
								(
								    (
								    _lowerCAmelCase
								)						,							(
								    _lowerCAmelCase
								)						,							(
								    _lowerCAmelCase
								)						,							
								)  						=config_and_inputs
								_lowerCAmelCase  						={"""pixel_values""": pixel_values}
								return config, inputs_dict


@require_torch
class        __lowerCamelCase      (				lowerCamelCase_				,		lowerCamelCase_				,		unittest.TestCase ):


				"""simple docstring"""







				a_:		Tuple					      =	(
				    (
				        SwinModel,
				        SwinBackbone,
				        SwinForImageClassification,
				        SwinForMaskedImageModeling,
				    )
				    if is_torch_available()
				    else ()
				)
				a_:		Tuple					      =	(
				    {"""feature-extraction""": SwinModel, """image-classification""": SwinForImageClassification}
				    if is_torch_available()
				    else {}
				)
				a_:		Union[str, Any]					      =	True

				a_:		Optional[int]					      =	False
				a_:		Dict					      =	False
				a_:		List[Any]					      =	False






				def        lowerCAmelCase__			(				self     :    Union[str, Any]					):
								_lowerCAmelCase  						=SwinModelTester(self					)
								_lowerCAmelCase  						=ConfigTester(self	,							config_class=lowerCamelCase_	,							embed_dim=37					)






				def        lowerCAmelCase__			(				self     :    Dict					):
								self.create_and_test_config_common_properties()
								self.config_tester.create_and_test_config_to_json_string()
								self.config_tester.create_and_test_config_to_json_file()
								self.config_tester.create_and_test_config_from_and_save_pretrained()
								self.config_tester.create_and_test_config_with_num_labels()
								self.config_tester.check_config_can_be_init_without_params()
								self.config_tester.check_config_arguments_init()






				def        lowerCAmelCase__			(				self     :    Union[str, Any]					):
								return






				def        lowerCAmelCase__			(				self     :    Optional[int]					):
								_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*lowerCamelCase_					)






				@unittest.skip(reason="""Got `CUDA error: misaligned address` with PyTorch 2.0.0."""					)
				def        lowerCAmelCase__			(				self     :    str					):
								pass






				def        lowerCAmelCase__			(				self     :    Optional[int]					):
								super().test_training_gradient_checkpointing()






				def        lowerCAmelCase__			(				self     :    Union[str, Any]					):
								_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_backbone(*lowerCamelCase_					)






				def        lowerCAmelCase__			(				self     :    Union[str, Any]					):
								_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_image_modeling(*lowerCamelCase_					)






				def        lowerCAmelCase__			(				self     :    Union[str, Any]					):
								_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*lowerCamelCase_					)






				@unittest.skip(reason="""Swin does not use inputs_embeds"""					)
				def        lowerCAmelCase__			(				self     :    Any					):
								pass






				@unittest.skip(reason="""Swin Transformer does not use feedforward chunking"""					)
				def        lowerCAmelCase__			(				self     :    Dict					):
								pass






				def        lowerCAmelCase__			(				self     :    str					):
								_lowerCAmelCase						,							_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
												_lowerCAmelCase  						=model_class(lowerCamelCase_					)
												self.assertIsInstance(model.get_input_embeddings()	,							(nn.Module)					)
												_lowerCAmelCase  						=model.get_output_embeddings()
												self.assertTrue(x is None or isinstance(lowerCamelCase_	,							nn.Linear					)					)






				def        lowerCAmelCase__			(				self     :    Dict					):
								_lowerCAmelCase						,							_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
												_lowerCAmelCase  						=model_class(lowerCamelCase_					)
												_lowerCAmelCase  						=inspect.signature(model.forward					)
												# signature.parameters is an OrderedDict => so arg_names order is deterministic
												_lowerCAmelCase  						=[*signature.parameters.keys()]

												_lowerCAmelCase  						=["""pixel_values"""]
												self.assertListEqual(arg_names[:1]	,							lowerCamelCase_					)






				def        lowerCAmelCase__			(				self     :    Optional[int]					):
								_lowerCAmelCase						,							_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs_for_common()
								_lowerCAmelCase  						=True

								for model_class in self.all_model_classes:
												_lowerCAmelCase  						=True
												_lowerCAmelCase  						=False
												_lowerCAmelCase  						=True
												_lowerCAmelCase  						=model_class(lowerCamelCase_					)
												model.to(lowerCamelCase_					)
												model.eval()
												with torch.no_grad():
																_lowerCAmelCase  						=model(**self._prepare_for_class(lowerCamelCase_	,							lowerCamelCase_					)					)
												_lowerCAmelCase  						=outputs.attentions
												_lowerCAmelCase  						=len(self.model_tester.depths					)
												self.assertEqual(len(lowerCamelCase_					)	,							lowerCamelCase_					)

												# check that output_attentions also work using config
												del inputs_dict["output_attentions"]
												_lowerCAmelCase  						=True
												_lowerCAmelCase  						=config.window_size**2
												_lowerCAmelCase  						=model_class(lowerCamelCase_					)
												model.to(lowerCamelCase_					)
												model.eval()
												with torch.no_grad():
																_lowerCAmelCase  						=model(**self._prepare_for_class(lowerCamelCase_	,							lowerCamelCase_					)					)
												_lowerCAmelCase  						=outputs.attentions
												self.assertEqual(len(lowerCamelCase_					)	,							lowerCamelCase_					)

												self.assertListEqual(
												    list(attentions[0].shape[-3:]					)	,							[self.model_tester.num_heads[0], window_size_squared, window_size_squared]	,							)
												_lowerCAmelCase  						=len(lowerCamelCase_					)

												# Check attention is always last and order is fine
												_lowerCAmelCase  						=True
												_lowerCAmelCase  						=True
												_lowerCAmelCase  						=model_class(lowerCamelCase_					)
												model.to(lowerCamelCase_					)
												model.eval()
												with torch.no_grad():
																_lowerCAmelCase  						=model(**self._prepare_for_class(lowerCamelCase_	,							lowerCamelCase_					)					)

												# also another +1 for reshaped_hidden_states
												_lowerCAmelCase  						=1 if model_class.__name__ == """SwinBackbone""" else 2
												self.assertEqual(out_len + added_hidden_states	,							len(lowerCamelCase_					)					)

												_lowerCAmelCase  						=outputs.attentions

												self.assertEqual(len(lowerCamelCase_					)	,							lowerCamelCase_					)

												self.assertListEqual(
												    list(self_attentions[0].shape[-3:]					)	,							[self.model_tester.num_heads[0], window_size_squared, window_size_squared]	,							)






				def        lowerCAmelCase__			(				self     :    str	,							lowerCamelCase_     :    Union[str, Any]	,							lowerCamelCase_     :    List[str]	,							lowerCamelCase_     :    Any	,							lowerCamelCase_     :    Tuple					):
								_lowerCAmelCase  						=model_class(lowerCamelCase_					)
								model.to(lowerCamelCase_					)
								model.eval()

								with torch.no_grad():
												_lowerCAmelCase  						=model(**self._prepare_for_class(lowerCamelCase_	,							lowerCamelCase_					)					)

								_lowerCAmelCase  						=outputs.hidden_states

								_lowerCAmelCase  						=getattr(
								    self.model_tester	,							"""expected_num_hidden_layers"""	,							len(self.model_tester.depths					) + 1					)
								self.assertEqual(len(lowerCamelCase_					)	,							lowerCamelCase_					)

								# Swin has a different seq_length
								_lowerCAmelCase  						=(
								    config.patch_size
								    if isinstance(config.patch_size	,							collections.abc.Iterable					)
								    else (config.patch_size, config.patch_size)
								)

								_lowerCAmelCase  						=(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

								self.assertListEqual(
								    list(hidden_states[0].shape[-2:]					)	,							[num_patches, self.model_tester.embed_dim]	,							)

								if not model_class.__name__ == "SwinBackbone":
												_lowerCAmelCase  						=outputs.reshaped_hidden_states
												self.assertEqual(len(lowerCamelCase_					)	,							lowerCamelCase_					)

												_lowerCAmelCase						,							_lowerCAmelCase						,							_lowerCAmelCase						,							_lowerCAmelCase  						=reshaped_hidden_states[0].shape
												_lowerCAmelCase  						=(
												    reshaped_hidden_states[0].view(lowerCamelCase_	,							lowerCamelCase_	,							height * width					).permute(0	,							2	,							1					)
												)
												self.assertListEqual(
												    list(reshaped_hidden_states.shape[-2:]					)	,							[num_patches, self.model_tester.embed_dim]	,							)






				def        lowerCAmelCase__			(				self     :    int					):
								_lowerCAmelCase						,							_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs_for_common()

								_lowerCAmelCase  						=(
								    self.model_tester.image_size
								    if isinstance(self.model_tester.image_size	,							collections.abc.Iterable					)
								    else (self.model_tester.image_size, self.model_tester.image_size)
								)

								for model_class in self.all_model_classes:
												_lowerCAmelCase  						=True
												self.check_hidden_states_output(lowerCamelCase_	,							lowerCamelCase_	,							lowerCamelCase_	,							lowerCamelCase_					)

												# check that output_hidden_states also work using config
												del inputs_dict["output_hidden_states"]
												_lowerCAmelCase  						=True

												self.check_hidden_states_output(lowerCamelCase_	,							lowerCamelCase_	,							lowerCamelCase_	,							lowerCamelCase_					)






				def        lowerCAmelCase__			(				self     :    Dict					):
								_lowerCAmelCase						,							_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs_for_common()
								_lowerCAmelCase  						=3

								_lowerCAmelCase  						=(
								    self.model_tester.image_size
								    if isinstance(self.model_tester.image_size	,							collections.abc.Iterable					)
								    else (self.model_tester.image_size, self.model_tester.image_size)
								)
								_lowerCAmelCase  						=(
								    config.patch_size
								    if isinstance(config.patch_size	,							collections.abc.Iterable					)
								    else (config.patch_size, config.patch_size)
								)

								_lowerCAmelCase  						=image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
								_lowerCAmelCase  						=image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

								for model_class in self.all_model_classes:
												_lowerCAmelCase  						=True
												self.check_hidden_states_output(lowerCamelCase_	,							lowerCamelCase_	,							lowerCamelCase_	,							(padded_height, padded_width)					)

												# check that output_hidden_states also work using config
												del inputs_dict["output_hidden_states"]
												_lowerCAmelCase  						=True
												self.check_hidden_states_output(lowerCamelCase_	,							lowerCamelCase_	,							lowerCamelCase_	,							(padded_height, padded_width)					)






				@slow
				def        lowerCAmelCase__			(				self     :    Optional[int]					):
								for model_name in SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												_lowerCAmelCase  						=SwinModel.from_pretrained(lowerCamelCase_					)
												self.assertIsNotNone(lowerCamelCase_					)






				def        lowerCAmelCase__			(				self     :    Optional[Any]					):
								_lowerCAmelCase						,							_lowerCAmelCase  						=self.model_tester.prepare_config_and_inputs_for_common()

								_lowerCAmelCase  						=_config_zero_init(lowerCamelCase_					)
								for model_class in self.all_model_classes:
												_lowerCAmelCase  						=model_class(config=lowerCamelCase_					)
												for name, param in model.named_parameters():
																if "embeddings" not in name and param.requires_grad:
																				self.assertIn(
																				    ((param.data.mean() * 1e9).round() / 1e9).item()	,							[0.0, 1.0]	,							msg=F"Parameter {name} of model {model_class} seems not properly initialized"	,							)


@require_vision
@require_torch
class        __lowerCamelCase      (				unittest.TestCase ):


				"""simple docstring"""







				@cached_property
				def        lowerCAmelCase__			(				self     :    str					):
								return (
								    AutoImageProcessor.from_pretrained("""microsoft/swin-tiny-patch4-window7-224"""					)
								    if is_vision_available()
								    else None
								)






				@slow
				def        lowerCAmelCase__			(				self     :    str					):
								_lowerCAmelCase  						=SwinForImageClassification.from_pretrained("""microsoft/swin-tiny-patch4-window7-224"""					).to(lowerCamelCase_					)
								_lowerCAmelCase  						=self.default_image_processor

								_lowerCAmelCase  						=Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""					)
								_lowerCAmelCase  						=image_processor(images=lowerCamelCase_	,							return_tensors="""pt"""					).to(lowerCamelCase_					)

								# forward pass
								with torch.no_grad():
												_lowerCAmelCase  						=model(**lowerCamelCase_					)

								# verify the logits
								_lowerCAmelCase  						=torch.Size((1, 1000)					)
								self.assertEqual(outputs.logits.shape	,							lowerCamelCase_					)
								_lowerCAmelCase  						=torch.tensor([-0.0948, -0.6454, -0.0921]					).to(lowerCamelCase_					)
								self.assertTrue(torch.allclose(outputs.logits[0, :3]	,							lowerCamelCase_	,							atol=1e-4					)					)


@require_torch
class        __lowerCamelCase      (				unittest.TestCase				,		lowerCamelCase_ ):


				"""simple docstring"""







				a_:		List[Any]					      =	(SwinBackbone,) if is_torch_available() else ()
				a_:		Union[str, Any]					      =	SwinConfig






				def        lowerCAmelCase__			(				self     :    Tuple					):
								_lowerCAmelCase  						=SwinModelTester(self					)





from math import floor, sqrt

def 		snake_case_   (				lowercase__     :    int     ):






				'''simple docstring'''






				_lowerCAmelCase  						=0.0
				_lowerCAmelCase  						=1.0
				_lowerCAmelCase  						=int(sqrt(lowercase__     )     )
				_lowerCAmelCase  						=root
				_lowerCAmelCase  						=0
				while integer_part != 2 * root:
								_lowerCAmelCase  						=denominator * integer_part - numerator
								_lowerCAmelCase  						=(n - numerator**2) / denominator
								_lowerCAmelCase  						=int((root + numerator) / denominator     )
								period += 1
				return period

def 		snake_case_   (				lowercase__     :    int = 1_00_00     ):






				'''simple docstring'''






				_lowerCAmelCase  						=0
				for i in range(2       ,     n + 1     ):
								_lowerCAmelCase  						=sqrt(lowercase__     )
								if sr - floor(lowercase__     ) != 0 and continuous_fraction_period(lowercase__     ) % 2 == 1:
												count_odd_periods += 1
				return count_odd_periods


if __name__ == "__main__":
		print(F'{solution(int(input().strip()))}')

