'''simple docstring'''






from collections.abc import Generator
from math import sin





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			bytes				):
     if len(__snake_case				) != 3_2:
          raise ValueError('Input must be of length 32'				)

     _A    		=  B''
     for i in [3, 2, 1, 0]:
          little_endian += string_aa[8 * i : 8 * i + 8]
     return little_endian





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int				):
     if i < 0:
          raise ValueError('Input must be non-negative'				)

     _A    		=  format(__snake_case   ,		'08x'				)[-8:]
     _A    		=  B''
     for i in [3, 2, 1, 0]:
          little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('utf-8'				)
     return little_endian_hex





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			bytes				):
     _A    		=  B''
     for char in message:
          bit_string += format(__snake_case   ,		'08b'				).encode('utf-8'				)
     _A    		=  format(len(__snake_case				)   ,		'064b'				).encode('utf-8'				)

     # Pad bit_string to a multiple of 512 chars
     bit_string += b"1"
     while len(__snake_case				) % 5_1_2 != 4_4_8:
          bit_string += b"0"
     bit_string += to_little_endian(start_len[3_2:]				) + to_little_endian(start_len[:3_2]				)

     return bit_string





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			bytes				):
     if len(__snake_case				) % 5_1_2 != 0:
          raise ValueError('Input must have length that\'s a multiple of 512'				)

     for pos in range(0   ,		len(__snake_case				)   ,		5_1_2				):
          _A    		=  bit_string[pos : pos + 5_1_2]
          _A    		=  []
          for i in range(0   ,		5_1_2   ,		3_2				):
               block_words.append(int(to_little_endian(block[i : i + 3_2]				)   ,		2				)				)
          yield block_words





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int				):
     if i < 0:
          raise ValueError('Input must be non-negative'				)

     _A    		=  format(__snake_case   ,		'032b'				)
     _A    		=  ''
     for c in i_str:
          new_str += "1" if c == "0" else "0"
     return int(__snake_case   ,		2				)





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int   ,		__snake_case							:			int				):
     return (a + b) % 2**3_2





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int   ,		__snake_case							:			int				):
     if i < 0:
          raise ValueError('Input must be non-negative'				)
     if shift < 0:
          raise ValueError('Shift must be non-negative'				)
     return ((i << shift) ^ (i >> (3_2 - shift))) % 2**3_2





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			bytes				):
     _A    		=  preprocess(__snake_case				)

     _A    		=  [int(2**3_2 * abs(sin(i + 1				)				)				) for i in range(6_4				)]

     # Starting states
     _A    		=  0X67_452_301
     _A    		=  0XEF_CDA_B89
     _A    		=  0X98_BAD_CFE
     _A    		=  0X10_325_476

     _A    		=  [
         7,
         1_2,
         1_7,
         2_2,
         7,
         1_2,
         1_7,
         2_2,
         7,
         1_2,
         1_7,
         2_2,
         7,
         1_2,
         1_7,
         2_2,
         5,
         9,
         1_4,
         2_0,
         5,
         9,
         1_4,
         2_0,
         5,
         9,
         1_4,
         2_0,
         5,
         9,
         1_4,
         2_0,
         4,
         1_1,
         1_6,
         2_3,
         4,
         1_1,
         1_6,
         2_3,
         4,
         1_1,
         1_6,
         2_3,
         4,
         1_1,
         1_6,
         2_3,
         6,
         1_0,
         1_5,
         2_1,
         6,
         1_0,
         1_5,
         2_1,
         6,
         1_0,
         1_5,
         2_1,
         6,
         1_0,
         1_5,
         2_1,
     ]

     # Process bit string in chunks, each with 16 32-char words
     for block_words in get_block_words(__snake_case				):
          _A    		=  aa
          _A    		=  ba
          _A    		=  ca
          _A    		=  da

          # Hash current chunk
          for i in range(6_4				):
               if i <= 1_5:
                    # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
                    _A    		=  d ^ (b & (c ^ d))
                    _A    		=  i
               elif i <= 3_1:
                    # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
                    _A    		=  c ^ (d & (b ^ c))
                    _A    		=  (5 * i + 1) % 1_6
               elif i <= 4_7:
                    _A    		=  b ^ c ^ d
                    _A    		=  (3 * i + 5) % 1_6
               else:
                    _A    		=  c ^ (b | not_aa(__snake_case				))
                    _A    		=  (7 * i) % 1_6
               _A    		=  (f + a + added_consts[i] + block_words[g]) % 2**3_2
               _A    		=  d
               _A    		=  c
               _A    		=  b
               _A    		=  sum_aa(__snake_case   ,		left_rotate_aa(__snake_case   ,		shift_amounts[i]				)				)

          # Add hashed chunk to running total
          _A    		=  sum_aa(__snake_case   ,		__snake_case				)
          _A    		=  sum_aa(__snake_case   ,		__snake_case				)
          _A    		=  sum_aa(__snake_case   ,		__snake_case				)
          _A    		=  sum_aa(__snake_case   ,		__snake_case				)

     _A    		=  reformat_hex(__snake_case				) + reformat_hex(__snake_case				) + reformat_hex(__snake_case				) + reformat_hex(__snake_case				)
     return digest


if __name__ == "__main__":
   import doctest

   doctest.testmod()




'''simple docstring'''






from __future__ import annotations





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int | str				):
     _A    		=  str(__snake_case				)
     return n == n[::-1]





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int = 1_0_0_0_0_0_0				):
     _A    		=  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()))))



