






import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import VideoMAEImageProcessor






class 							A_				(	unittest.TestCase      ):


     def __init__(							self    :	List[str]    ,						UpperCAmelCase    :	List[str]    ,						UpperCAmelCase    :	int=7    ,						UpperCAmelCase    :	List[str]=3    ,						UpperCAmelCase    :	Union[str, Any]=1_0    ,						UpperCAmelCase    :	Tuple=1_8    ,						UpperCAmelCase    :	Tuple=3_0    ,						UpperCAmelCase    :	Tuple=4_0_0    ,						UpperCAmelCase    :	Any=True    ,						UpperCAmelCase    :	int=None    ,						UpperCAmelCase    :	Optional[Any]=True    ,						UpperCAmelCase    :	Any=[0.5, 0.5, 0.5]    ,						UpperCAmelCase    :	Any=[0.5, 0.5, 0.5]    ,						UpperCAmelCase    :	Any=None    ,						)							->			Any:
      __lowerCAmelCase:     List[str]     			=   size if size is not None else {"shortest_edge": 1_8}
      __lowerCAmelCase:     Tuple     			=   crop_size if crop_size is not None else {"height": 1_8, "width": 1_8}

      __lowerCAmelCase:     Any     			=   parent
      __lowerCAmelCase:     int     			=   batch_size
      __lowerCAmelCase:     str     			=   num_channels
      __lowerCAmelCase:     List[Any]     			=   num_frames
      __lowerCAmelCase:     List[Any]     			=   image_size
      __lowerCAmelCase:     List[Any]     			=   min_resolution
      __lowerCAmelCase:     str     			=   max_resolution
      __lowerCAmelCase:     Optional[int]     			=   do_resize
      __lowerCAmelCase:     Optional[int]     			=   size
      __lowerCAmelCase:     Optional[int]     			=   do_normalize
      __lowerCAmelCase:     Dict     			=   image_mean
      __lowerCAmelCase:     Optional[Any]     			=   image_std
      __lowerCAmelCase:     int     			=   crop_size


     def 						UpperCAmelCase						(							self    :	Dict      )							->			Dict:
      return {
          "image_mean": self.image_mean,
          "image_std": self.image_std,
          "do_normalize": self.do_normalize,
          "do_resize": self.do_resize,
          "size": self.size,
          "crop_size": self.crop_size,
      }







@require_torch
@require_vision
class 							A_				(	A__							,			unittest.TestCase      ):
     _lowercase    :  Union[str, Any]          =			VideoMAEImageProcessor if is_vision_available() else None


     def 						UpperCAmelCase						(							self    :	Any      )							->			List[Any]:
      __lowerCAmelCase:     Any     			=   VideoMAEImageProcessingTester(self      )


     @property
     def 						UpperCAmelCase						(							self    :	str      )							->			Any:
      return self.image_processor_tester.prepare_image_processor_dict()


     def 						UpperCAmelCase						(							self    :	Dict      )							->			int:
      __lowerCAmelCase:     Optional[int]     			=   self.image_processing_class(**self.image_processor_dict      )
      self.assertTrue(hasattr(UpperCAmelCase    ,						'image_mean'      )      )
      self.assertTrue(hasattr(UpperCAmelCase    ,						'image_std'      )      )
      self.assertTrue(hasattr(UpperCAmelCase    ,						'do_normalize'      )      )
      self.assertTrue(hasattr(UpperCAmelCase    ,						'do_resize'      )      )
      self.assertTrue(hasattr(UpperCAmelCase    ,						'do_center_crop'      )      )
      self.assertTrue(hasattr(UpperCAmelCase    ,						'size'      )      )


     def 						UpperCAmelCase						(							self    :	str      )							->			Optional[int]:
      __lowerCAmelCase:     List[Any]     			=   self.image_processing_class.from_dict(self.image_processor_dict      )
      self.assertEqual(image_processor.size    ,						{'shortest_edge': 1_8}      )
      self.assertEqual(image_processor.crop_size    ,						{'height': 1_8, 'width': 1_8}      )

      __lowerCAmelCase:     Union[str, Any]     			=   self.image_processing_class.from_dict(self.image_processor_dict    ,						size=4_2    ,						crop_size=8_4      )
      self.assertEqual(image_processor.size    ,						{'shortest_edge': 4_2}      )
      self.assertEqual(image_processor.crop_size    ,						{'height': 8_4, 'width': 8_4}      )


     def 						UpperCAmelCase						(							self    :	Any      )							->			Union[str, Any]:
      pass


     def 						UpperCAmelCase						(							self    :	int      )							->			Union[str, Any]:
      __lowerCAmelCase:     Optional[Any]     			=   self.image_processing_class(**self.image_processor_dict      )
      # create random PIL videos
      __lowerCAmelCase:     Optional[Any]     			=   prepare_video_inputs(self.image_processor_tester    ,						equal_resolution=UpperCAmelCase      )
      for video in video_inputs:
       self.assertIsInstance(UpperCAmelCase    ,						UpperCAmelCase      )
       self.assertIsInstance(video[0]    ,						Image.Image      )

      # Test not batched input
      __lowerCAmelCase:     List[Any]     			=   image_processing(video_inputs[0]    ,						return_tensors='pt'      ).pixel_values
      self.assertEqual(
          encoded_videos.shape    ,						(
              1,
              self.image_processor_tester.num_frames,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.crop_size['height'],
              self.image_processor_tester.crop_size['width'],
          )    ,						)

      # Test batched
      __lowerCAmelCase:     Any     			=   image_processing(UpperCAmelCase    ,						return_tensors='pt'      ).pixel_values
      self.assertEqual(
          encoded_videos.shape    ,						(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_frames,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.crop_size['height'],
              self.image_processor_tester.crop_size['width'],
          )    ,						)


     def 						UpperCAmelCase						(							self    :	Dict      )							->			List[Any]:
      __lowerCAmelCase:     Tuple     			=   self.image_processing_class(**self.image_processor_dict      )
      # create random numpy tensors
      __lowerCAmelCase:     Dict     			=   prepare_video_inputs(self.image_processor_tester    ,						equal_resolution=UpperCAmelCase    ,						numpify=UpperCAmelCase      )
      for video in video_inputs:
       self.assertIsInstance(UpperCAmelCase    ,						UpperCAmelCase      )
       self.assertIsInstance(video[0]    ,						np.ndarray      )

      # Test not batched input
      __lowerCAmelCase:     Optional[int]     			=   image_processing(video_inputs[0]    ,						return_tensors='pt'      ).pixel_values
      self.assertEqual(
          encoded_videos.shape    ,						(
              1,
              self.image_processor_tester.num_frames,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.crop_size['height'],
              self.image_processor_tester.crop_size['width'],
          )    ,						)

      # Test batched
      __lowerCAmelCase:     Any     			=   image_processing(UpperCAmelCase    ,						return_tensors='pt'      ).pixel_values
      self.assertEqual(
          encoded_videos.shape    ,						(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_frames,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.crop_size['height'],
              self.image_processor_tester.crop_size['width'],
          )    ,						)


     def 						UpperCAmelCase						(							self    :	str      )							->			Optional[Any]:
      __lowerCAmelCase:     Optional[Any]     			=   self.image_processing_class(**self.image_processor_dict      )
      # create random PyTorch tensors
      __lowerCAmelCase:     List[str]     			=   prepare_video_inputs(self.image_processor_tester    ,						equal_resolution=UpperCAmelCase    ,						torchify=UpperCAmelCase      )
      for video in video_inputs:
       self.assertIsInstance(UpperCAmelCase    ,						UpperCAmelCase      )
       self.assertIsInstance(video[0]    ,						torch.Tensor      )

      # Test not batched input
      __lowerCAmelCase:     str     			=   image_processing(video_inputs[0]    ,						return_tensors='pt'      ).pixel_values
      self.assertEqual(
          encoded_videos.shape    ,						(
              1,
              self.image_processor_tester.num_frames,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.crop_size['height'],
              self.image_processor_tester.crop_size['width'],
          )    ,						)

      # Test batched
      __lowerCAmelCase:     Dict     			=   image_processing(UpperCAmelCase    ,						return_tensors='pt'      ).pixel_values
      self.assertEqual(
          encoded_videos.shape    ,						(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_frames,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.crop_size['height'],
              self.image_processor_tester.crop_size['width'],
          )    ,						)








from math import floor, sqrt







def _a				( SCREAMING_SNAKE_CASE	:    int	)					->					int:

 """simple docstring"""






 __lowerCAmelCase:     Optional[int]     			=   0.0
 __lowerCAmelCase:     Any     			=   1.0
 __lowerCAmelCase:     List[str]     			=   int(sqrt(SCREAMING_SNAKE_CASE	)	)
 __lowerCAmelCase:     Union[str, Any]     			=   root
 __lowerCAmelCase:     List[str]     			=   0
 while integer_part != 2 * root:
  __lowerCAmelCase:     List[str]     			=   denominator * integer_part - numerator
  __lowerCAmelCase:     Optional[int]     			=   (n - numerator**2) / denominator
  __lowerCAmelCase:     Union[str, Any]     			=   int((root + numerator) / denominator	)
  period += 1
 return period







def _a				( SCREAMING_SNAKE_CASE	:    int = 1_00_00	)					->					int:

 """simple docstring"""






 __lowerCAmelCase:     Optional[int]     			=   0
 for i in range(2					,      n + 1	):
  __lowerCAmelCase:     List[str]     			=   sqrt(SCREAMING_SNAKE_CASE	)
  if sr - floor(SCREAMING_SNAKE_CASE	) != 0 and continuous_fraction_period(SCREAMING_SNAKE_CASE	) % 2 == 1:
   count_odd_periods += 1
 return count_odd_periods


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





