

import json
import os
from collections import Counter

import torch
import torchvision
import torchvision.transforms as transforms
from PIL import Image
from torch import nn
from torch.utils.data import Dataset


lowerCamelCase           =					{1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2), 7: (7, 1), 8: (4, 2), 9: (3, 3)}







class 						__magic_name__			(							nn.Module							):

   '''simple docstring'''




   def __init__(				self,    lowercase_       )							->    List[str]:






     """simple docstring"""






     super().__init__()
     a__  =torchvision.models.resnetaaa(pretrained=lowercase_       )
     a__  =list(model.children()       )[:-2]
     a__  =nn.Sequential(*lowercase_       )
     a__  =nn.AdaptiveAvgPoolad(POOLING_BREAKDOWN[args.num_image_embeds]       )



   def  _UpperCAmelCase (				self,    lowercase_       )							->    Any:






     """simple docstring"""






     a__  =self.pool(self.model(lowercase_       )       )
     a__  =torch.flatten(lowercase_,    start_dim=2       )
     a__  =out.transpose(1,    2       ).contiguous()
     return out  # BxNx2048







class 						__magic_name__			(							lowerCamelCase__							):

   '''simple docstring'''




   def __init__(				self,    lowercase_,    lowercase_,    lowercase_,    lowercase_,    lowercase_       )							->    str:






     """simple docstring"""






     a__  =[json.loads(lowercase_       ) for l in open(lowercase_       )]
     a__  =os.path.dirname(lowercase_       )
     a__  =tokenizer
     a__  =labels
     a__  =len(lowercase_       )
     a__  =max_seq_length

     a__  =transforms



   def __len__(				self       )							->    Optional[Any]:






     """simple docstring"""






     return len(self.data       )



   def __getitem__(				self,    lowercase_       )							->    Dict:






     """simple docstring"""






     a__  =torch.LongTensor(self.tokenizer.encode(self.data[index]['''text'''],    add_special_tokens=lowercase_       )       )
     a__,      a__,      a__  =sentence[0], sentence[1:-1], sentence[-1]
     a__  =sentence[: self.max_seq_length]

     a__  =torch.zeros(self.n_classes       )
     a__  =1

     a__  =Image.open(os.path.join(self.data_dir,    self.data[index]['''img''']       )       ).convert('''RGB'''       )
     a__  =self.transforms(lowercase_       )

     return {
         "image_start_token": start_token,
         "image_end_token": end_token,
         "sentence": sentence,
         "image": image,
         "label": label,
     }



   def  _UpperCAmelCase (				self       )							->    List[str]:






     """simple docstring"""






     a__  =Counter()
     for row in self.data:
       label_freqs.update(row['''label''']       )
     return label_freqs





def 			UpperCAmelCase__				(			_A      : List[str]							):





  '''simple docstring'''







  a__  =[len(row['''sentence''']							) for row in batch]
  a__,      a__  =len(_A							), max(_A							)

  a__  =torch.zeros(_A	,      _A	,      dtype=torch.long							)
  a__  =torch.zeros(_A	,      _A	,      dtype=torch.long							)

  for i_batch, (input_row, length) in enumerate(zip(_A	,      _A							)							):
    a__  =input_row['''sentence''']
    a__  =1

  a__  =torch.stack([row['''image'''] for row in batch]							)
  a__  =torch.stack([row['''label'''] for row in batch]							)
  a__  =torch.stack([row['''image_start_token'''] for row in batch]							)
  a__  =torch.stack([row['''image_end_token'''] for row in batch]							)

  return text_tensor, mask_tensor, img_tensor, img_start_token, img_end_token, tgt_tensor




def 			UpperCAmelCase__				(			):





  '''simple docstring'''







  return [
      "Crime",
      "Drama",
      "Thriller",
      "Action",
      "Comedy",
      "Romance",
      "Documentary",
      "Short",
      "Mystery",
      "History",
      "Family",
      "Adventure",
      "Fantasy",
      "Sci-Fi",
      "Western",
      "Horror",
      "Sport",
      "War",
      "Music",
      "Musical",
      "Animation",
      "Biography",
      "Film-Noir",
  ]




def 			UpperCAmelCase__				(			):





  '''simple docstring'''







  return transforms.Compose(
      [
          transforms.Resize(2_56							),
          transforms.CenterCrop(2_24							),
          transforms.ToTensor(),
          transforms.Normalize(
              mean=[0.46_777_044, 0.44_531_429, 0.40_661_017]	,      std=[0.12_221_994, 0.12_145_835, 0.14_380_469]	,      ),
      ]							)



from math import factorial




def 			UpperCAmelCase__				(			_A      : int = 1_00							):





  '''simple docstring'''







  return sum(int(_A							) for x in str(factorial(_A							)							)							)


if __name__ == "__main__":
       print(solution(int(input('''Enter the Number: ''').strip())))
