

import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union

import pandas as pd
import pyarrow as pa

import datasets
import datasets.config
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


if TYPE_CHECKING:
  import sqlitea

  import sqlalchemy


_a 	=       datasets.utils.logging.get_logger(__name__)






@dataclass
class 							A_			(		datasets.BuilderConfig ):
     _lowercase      :					Optional[int]       =     None
     _lowercase      :					Dict       =     None
     _lowercase      :					Dict       =     None
     _lowercase      :					int       =     True
     _lowercase      :					Any       =     None
     _lowercase      :					Any       =     None
     _lowercase      :					List[str]       =     None
     _lowercase      :					Optional[int]       =     1_0_0_0_0
     _lowercase      :					List[Any]       =     None


     def   UpperCAmelCase  (							self      :		Dict )							->     Any:


      if self.sql is None:
       raise ValueError('sql must be specified' )
      if self.con is None:
       raise ValueError('con must be specified' )


     def   UpperCAmelCase  (							self      :		str      ,  UpperCAmelCase      :		Union[str, Any]      ,  UpperCAmelCase      :		List[str] = None      ,  )							->     Union[str, Any]:
      __lowerCAmelCase:       Tuple            =				config_kwargs.copy()
      # We need to stringify the Selectable object to make its hash deterministic

      # The process of stringifying is explained here: http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html
      __lowerCAmelCase:       Optional[int]            =				config_kwargs['sql']
      if not isinstance(snake_case__      ,  snake_case__ ):
       if datasets.config.SQLALCHEMY_AVAILABLE and "sqlalchemy" in sys.modules:
        import sqlalchemy

        if isinstance(snake_case__      ,  sqlalchemy.sql.Selectable ):
         __lowerCAmelCase:       Dict            =				sqlalchemy.create_engine(config_kwargs['con'].split('://' )[0] + '://' )
         __lowerCAmelCase:       List[str]            =				str(sql.compile(dialect=engine.dialect ) )
         __lowerCAmelCase:       Any            =				sql_str
        else:
         raise TypeError(
             F'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(snake_case__ )}: {sql}''' )
       else:
        raise TypeError(
            F'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(snake_case__ )}: {sql}''' )
      __lowerCAmelCase:       Dict            =				config_kwargs['con']
      if not isinstance(snake_case__      ,  snake_case__ ):
       __lowerCAmelCase:       Any            =				id(snake_case__ )
       logger.info(
           F'''SQL connection \'con\' of type {type(snake_case__ )} couldn\'t be hashed properly. To enable hashing, specify \'con\' as URI string instead.''' )

      return super().create_config_id(snake_case__      ,  custom_features=snake_case__ )


     @property
     def   UpperCAmelCase  (							self      :		Dict )							->     Tuple:
      __lowerCAmelCase:       Optional[Any]            =				{
          'index_col': self.index_col,
          'columns': self.columns,
          'params': self.params,
          'coerce_float': self.coerce_float,
          'parse_dates': self.parse_dates,
      }
      return pd_read_sql_kwargs







class 							A_			(		datasets.ArrowBasedBuilder ):
     _lowercase      :					Optional[Any]       =     SqlConfig


     def   UpperCAmelCase  (							self      :		Tuple )							->     Union[str, Any]:
      return datasets.DatasetInfo(features=self.config.features )


     def   UpperCAmelCase  (							self      :		Dict      ,  UpperCAmelCase      :		Any )							->     Union[str, Any]:
      return [datasets.SplitGenerator(name=datasets.Split.TRAIN      ,  gen_kwargs={} )]


     def   UpperCAmelCase  (							self      :		List[str]      ,  UpperCAmelCase      :		List[str] )							->     Tuple:


      if self.config.features is not None:
       __lowerCAmelCase:       Optional[Any]            =				self.config.features.arrow_schema
       if all(not require_storage_cast(snake_case__ ) for feature in self.config.features.values() ):
        # cheaper cast
        __lowerCAmelCase:       int            =				pa.Table.from_arrays([pa_table[field.name] for field in schema]      ,  schema=snake_case__ )
       else:
        # more expensive cast; allows str <-> int/float or str to Audio for example
        __lowerCAmelCase:       str            =				table_cast(snake_case__      ,  snake_case__ )
      return pa_table


     def   UpperCAmelCase  (							self      :		int )							->     Union[str, Any]:
      __lowerCAmelCase:       Optional[Any]            =				self.config.chunksize
      __lowerCAmelCase:       Dict            =				pd.read_sql(
          self.config.sql      ,  self.config.con      ,  chunksize=snake_case__      ,  **self.config.pd_read_sql_kwargs )
      __lowerCAmelCase:       str            =				[sql_reader] if chunksize is None else sql_reader
      for chunk_idx, df in enumerate(snake_case__ ):
       __lowerCAmelCase:       Optional[int]            =				pa.Table.from_pandas(snake_case__ )
       yield chunk_idx, self._cast_table(snake_case__ )








def _a			(	SCREAMING_SNAKE_CASE		:      int = 10_00		)   ->   int:

 """simple docstring"""






 __lowerCAmelCase:       Union[str, Any]            =				[0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8]
 # number of letters in twenty, thirty, ..., ninety (0 for numbers less than
 # 20 due to inconsistency in teens)
 __lowerCAmelCase:       Union[str, Any]            =				[0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

 __lowerCAmelCase:       Optional[int]            =				0

 for i in range(1   , n + 1		):
  if i < 10_00:
   if i >= 1_00:
    # add number of letters for "n hundred"
    count += ones_counts[i // 1_00] + 7

    if i % 1_00 != 0:
     # add number of letters for "and" if number is not multiple
     # of 100
     count += 3

   if 0 < i % 1_00 < 20:
    # add number of letters for one, two, three, ..., nineteen
    # (could be combined with below if not for inconsistency in
    # teens)
    count += ones_counts[i % 1_00]
   else:
    # add number of letters for twenty, twenty one, ..., ninety
    # nine
    count += ones_counts[i % 10]
    count += tens_counts[(i % 1_00 - i % 10) // 10]
  else:
   count += ones_counts[i // 10_00] + 8
 return count


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





