



"""simple docstring"""







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


UpperCAmelCase:  Optional[int]			     =				datasets.utils.logging.get_logger(__name__)





@dataclass
class   UpperCamelCase	(     datasets.BuilderConfig       ):




	"""simple docstring"""
	SCREAMING_SNAKE_CASE_							:       Union[str, "sqlalchemy.sql.Selectable"]						       =  None
	SCREAMING_SNAKE_CASE_							:       Union[str, "sqlalchemy.engine.Connection", "sqlalchemy.engine.Engine", "sqlite3.Connection"]						       =  None
	SCREAMING_SNAKE_CASE_							:       Optional[Union[str, List[str]]]						       =  None
	SCREAMING_SNAKE_CASE_							:       bool						       =  True
	SCREAMING_SNAKE_CASE_							:       Optional[Union[List, Tuple, Dict]]						       =  None
	SCREAMING_SNAKE_CASE_							:       Optional[Union[List, Dict]]						       =  None
	SCREAMING_SNAKE_CASE_							:       Optional[List[str]]						       =  None
	SCREAMING_SNAKE_CASE_							:       Optional[int]						       =  1_0_0_0_0
	SCREAMING_SNAKE_CASE_							:       Optional[datasets.Features]						       =  None






	def    lowerCamelCase__					(     self   ):
			if self.sql is None:
					raise ValueError("""sql must be specified"""   )
			if self.con is None:
					raise ValueError("""con must be specified"""   )






	def    lowerCamelCase__					(     self				,UpperCAmelCase_				,UpperCAmelCase_ = None				,):
			_lowercase				: Optional[Any]     =   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
			_lowercase				: Optional[Any]     =   config_kwargs["""sql"""]
			if not isinstance(UpperCAmelCase_				,UpperCAmelCase_   ):
					if datasets.config.SQLALCHEMY_AVAILABLE and "sqlalchemy" in sys.modules:
							import sqlalchemy

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

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






	@property
	def    lowerCamelCase__					(     self   ):
			_lowercase				: Optional[int]     =   {
			    """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   UpperCamelCase	(     datasets.ArrowBasedBuilder       ):




	"""simple docstring"""
	SCREAMING_SNAKE_CASE_							:       int						       =  SqlConfig






	def    lowerCamelCase__					(     self   ):
			return datasets.DatasetInfo(features=self.config.features   )






	def    lowerCamelCase__					(     self				,UpperCAmelCase_   ):
			return [datasets.SplitGenerator(name=datasets.Split.TRAIN				,gen_kwargs={}   )]






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






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








"""simple docstring"""







from math import floor, sqrt


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase      ):
		_lowercase				: Optional[int]     =   0.0
		_lowercase				: Dict     =   1.0
		_lowercase				: Optional[int]     =   int(sqrt(__UpperCAmelCase      )      )
		_lowercase				: Optional[Any]     =   root
		_lowercase				: Dict     =   0
		while integer_part != 2 * root:
				_lowercase				: str     =   denominator * integer_part - numerator
				_lowercase				: Optional[int]     =   (n - numerator**2) / denominator
				_lowercase				: List[str]     =   int((root + numerator) / denominator      )
				period += 1
		return period


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase = 10000      ):
		_lowercase				: List[str]     =   0
		for i in range(2   ,				n + 1      ):
				_lowercase				: Dict     =   sqrt(__UpperCAmelCase      )
				if sr - floor(__UpperCAmelCase      ) != 0 and continuous_fraction_period(__UpperCAmelCase      ) % 2 == 1:
						count_odd_periods += 1
		return count_odd_periods


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



