#K90422. Bit Palindrome Challenge

    ID: 37749 Type: Default 1000ms 256MiB

Bit Palindrome Challenge

Bit Palindrome Challenge

Given an integer \(n\), count the numbers between 1 and \(n\) whose binary representations are palindromic. A binary palindrome is a number whose binary representation reads the same forwards and backwards. For example, 5 is a bit palindrome since its binary representation is \(101\).

Your task is to implement a solution that reads an integer from standard input and outputs the count of bit palindromes among the numbers \(1\) through \(n\). The binary representation of a number \(x\) is obtained by writing \(x\) in base 2 without leading zeros.

inputFormat

A single integer (n) (1 ≤ n ≤ 10^9) provided via standard input.

outputFormat

Output a single integer representing the count of bit palindromes between 1 and (n) (inclusive) to standard output.## sample

1
1