Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
G. New Year and Binary Tree Paths

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThe New Year tree is an infinite perfect binary tree rooted in the node 1. Each node *v* has two children: nodes indexed (2·*v*) and (2·*v* + 1).

Polar bears love decorating the New Year tree and Limak is no exception. As he is only a little bear, he was told to decorate only one simple path between some pair of nodes. Though he was given an opportunity to pick the pair himself! Now he wants to know the number of unordered pairs of indices (*u*, *v*) (*u* ≤ *v*), such that the sum of indices of all nodes along the simple path between *u* and *v* (including endpoints) is equal to *s*. Can you help him and count this value?

Input

The only line of the input contains a single integer *s* (1 ≤ *s* ≤ 10^{15}).

Output

Print one integer, denoting the number of unordered pairs of nodes indices defining simple paths with the sum of indices of vertices equal to *s*.

Example

Input

10

Output

4

Note

In sample test, there are 4 paths with the sum of indices equal to 10:

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/04/2022 02:53:38 (j3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|