
import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment







@require_huggingface_suite
class 				lowercase		(					unittest.TestCase		):




							def  A__      (				self):
												lowercase							=						inspect.getfile(accelerate.test_utils)
												lowercase							=						os.path.sep.join(
												    mod_file.split(os.path.sep)[:-1] + ['''scripts''', '''external_deps''', '''test_metrics.py'''])

												from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

												lowercase							=						test_metrics




							@require_cpu
							def  A__      (				self):
												debug_launcher(self.test_metrics.main   ,num_processes=1)




							@require_cpu
							def  A__      (				self):
												debug_launcher(self.test_metrics.main)




							@require_single_gpu
							def  A__      (				self):
												self.test_metrics.main()





							@require_multi_gpu
							def  A__      (				self):
												print(f'Found {torch.cuda.device_count()} devices.')
												lowercase							=						['''torchrun''', f'--nproc_per_node={torch.cuda.device_count()}', self.test_file_path]
												with patch_environment(omp_num_threads=1):
																	execute_subprocess_async(a_   ,env=os.environ.copy())








"""simple docstring"""
from __future__ import annotations






def 		lowercase							(     _snake_case						:      int | str     )     ->bool:
	"""simple docstring"""





	__snake_case	:						List[str]						=				str(_snake_case     )
	return n == n[::-1]






def 		lowercase							(     _snake_case						:      int = 1_000_000     )     ->str:
	"""simple docstring"""





	__snake_case	:						Union[str, Any]						=				0

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


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





