



'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


snake_case_			=     {
    """configuration_timesformer""": ["""TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimesformerConfig"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case_			=     [
	    """TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TimesformerModel""",
	    """TimesformerForVideoClassification""",
	    """TimesformerPreTrainedModel""",
	]

if TYPE_CHECKING:
	from .configuration_timesformer import TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, TimesformerConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_timesformer import (
		    TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TimesformerForVideoClassification,
		    TimesformerModel,
		    TimesformerPreTrainedModel,
		)

else:
	import sys

	snake_case_			=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)









'''simple docstring'''

from __future__ import annotations






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int | str       ):
				SCREAMING_SNAKE_CASE  :						int      					= str(_SCREAMING_SNAKE_CASE       )
				return n == n[::-1]






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int = 1_00_00_00       ):
				SCREAMING_SNAKE_CASE  :						int      					= 0

				for i in range(1    ,	_SCREAMING_SNAKE_CASE       ):
								if is_palindrome(_SCREAMING_SNAKE_CASE       ) and is_palindrome(bin(_SCREAMING_SNAKE_CASE       ).split('''b'''       )[1]       ):
												total += i
				return total


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




