시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB62240.000%

문제

Let us consider a sequence of alternatively changing zeroes and ones, starting with one. This sequence can be seen as a binary representation of a positive integer. We want to present it as a sum of different binary numbers, composed only of ones (i.e. 1, 11, 111 and etc). For some sequences such presentation is possible, for others not.

For example: 10102=112+1112; 10101012=1112+11112+1111112; 101010101012 cannot be presented as desired.

Write a program to find for a given sequence of zeros and ones the number of summands in one presentation as a sum of different binary numbers, composed only of ones, or determines that there is no such presentation.

입력

The first line of the standard input contains only one positive integer n – the length of the considered sequence.

출력

The only line of the standard output should only contain one non-negative integer: the number of different summands of the desired presentation or 0, if there is no such presentation.

If there is more than one possible solution, output the number of summands in any of them.

제한

  • 1 ≤ n ≤ 2·109

서브태스크

번호배점제한
110

n ≤ 60

220

n ≤ 103

330

n ≤ 106

440

n ≤ 2·109

예제 입력 1

6

예제 출력 1

4

1010102=12+112+1112+111112 (42=1+3+7+31)

예제 입력 2

5

예제 출력 2

0

The number 101012=21 cannot be presented as desired.

채점 및 기타 정보

  • 예제는 채점하지 않는다.