One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.

But his plan failed. The reason for this was very simple: Hexadecimal didn't perceive any information, apart from numbers written in binary format. This means that if a number in a decimal representation contained characters apart from 0 and 1, it was not stored in the memory. Now Megabyte wants to know, how many numbers were loaded successfully.

Input

Input data contains the only number n (1 ≤ n ≤ 109).

Output

Output the only number — answer to the problem.

Examples

Input

10


Output

2

Note

For n = 10 the answer includes numbers 1 and 10.
def main():
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    inf = 1e17
    mod = 10 ** 9 + 7

    # Max = 10 ** 1
    # primes = []
    # prime = [True for i in range(Max + 1)]
    # p = 2
    # while (p * p <= Max + 1):
    #
    #     # If prime[p] is not
    #     # changed, then it is a prime
    #     if (prime[p] == True):
    #
    #         # Update all multiples of p
    #         for i in range(p * p, Max + 1, p):
    #             prime[i] = False
    #     p += 1
    #
    # for p in range(2, Max + 1):
    #     if prime[p]:
    #         primes.append(p)
    #
    # print(primes)

    def factorial(n):
        f = 1

        for i in range(1, n + 1):
            f = (f * i) % mod  # Now f never can
        # exceed 10^9+7

        return f

    def ncr(n, r):
        # initialize numerator
        # and denominator
        num = den = 1
        for i in range(r):
            num = (num * (n - i)) % mod
            den = (den * (i + 1)) % mod
        return (num * pow(den,
                          mod - 2, mod)) % mod


    def solve(n):

        cnt = 0
        for i in range(1,pow(2,len(str(n)))):

            if int(bin(i)[2:]) <= n:
                cnt += 1

        print(cnt)















































        pass

    t = 1#int(input())
    ans = []
    for _ in range(t):
        n = int(input())
        #n,m = map(int, input().split())
        # s = input()
        #arr = [int(x) for x in input().split()]
        # a2 = [int(x) for x in input().split()]
        # grid = []
        # for i in range(n):
        #     grid.append([int(x) for x in input().split()][::-1])

        ans.append(solve(n))

    # for answer in ans:
    #     print(answer)


if __name__ == "__main__":
    import sys, threading
    import bisect
    import math
    import itertools
    from sys import stdout

    # Sorted Containers
    import heapq
    from queue import PriorityQueue

    # Tree Problems
    #sys.setrecursionlimit(2 ** 32 // 2 - 1)
    #threading.stack_size(1 << 27)

    # fast io
    input = sys.stdin.readline

    thread = threading.Thread(target=main)
    thread.start()
    thread.join()
