



'''simple docstring'''


from __future__ import annotations







def 				__lowerCamelCase				(   A__    )       ->	Dict:






   """simple docstring"""
   UpperCamelCase					=  str(A__    )
   return n == n[::-1]







def 				__lowerCamelCase				(   A__ = 1_000_000    )       ->	Any:






   """simple docstring"""
   UpperCamelCase					=  0

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


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





'''simple docstring'''






def 				UpperCamelCase_			(    A__					:   int = 10_00					):
  '''simple docstring'''





  lowerCAmelCase_			:      Optional[Any]			=   3
  lowerCAmelCase_			:      Dict			=   0
  while a < n:
    if a % 3 == 0 or a % 5 == 0:
      result += a
    elif a % 15 == 0:
      result -= a
    a += 1
  return result


if __name__ == "__main__":
  print(F'''{solution() = }''')



