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.
###################################################################
#                  ."-,.__
#                  `.     `.  ,
#               .--'  .._,'"-' `.
#              .    .'         `'
#              `.   /          ,'
#                `  '--.   ,-"'
#                 `"`   |  \
#                    -. \, |
#                     `--Y.'      ___.
#                          \     L._, \
#                _.,        `.   <  <\                _
#              ,' '           `, `.   | \            ( `
#           ../, `.            `  |    .\`.           \ \_
#          ,' ,..  .           _.,'    ||\l            )  '".
#         , ,'   \           ,'.-.`-._,'  |           .  _._`.
#       ,' /      \ \        `' ' `--/   | \          / /   ..\
#     .'  /        \ .         |\__ - _ ,'` `        / /     `.`.
#     |  '          ..         `-...-"  |  `-'      / /        . `.
#     | /           |L__           |    |          / /          `. `.
#    , /            .   .          |    |         / /             ` `
#   / /          ,. ,`._ `-_       |    |  _   ,-' /               ` \
#  / .           \"`_/. `-_ \_,.  ,'    +-' `-'  _,        ..,-.    \`.
# .  '         .-f    ,'   `    '.       \__.---'     _   .'   '     \ \
# ' /          `.'    l     .' /          \..      ,_|/   `.  ,'`     L`
# |'      _.-""` `.    \ _,'  `            \ `.___`.'"`-.  , |   |    | \
# ||    ,'      `. `.   '       _,...._        `  |    `/ '  |   '     .|
# ||  ,'          `. ;.,.---' ,'       `.   `.. `-'  .-' /_ .'    ;_   ||
# || '              V      / /           `   | `   ,'   ,' '.    !  `. ||
# ||/            _,-------7 '              . |  `-'    l         /    `||
# . |          ,' .-   ,' ||               | .-.        `.      .'     ||
#  `'        ,'    `".'    |               |    `.        '. -.'       `'
#           /      ,'      |               |,'    \-.._,.'/'
#           .     /        .               .       \    .''
#         .`.    |         `.             /         :_,'.'
#           \ `...\   _     ,'-.        .'         /_.-'
#            `-.__ `,  `'   .  _.>----''.  _  __  /
#                 .'        /"'          |  "'   '_
#                /_|.-'\ ,".             '.'`__'-( \
#                  / ,"'"\,'               `/  `-.|" 
###################################################################

from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
        
mod = pow(10, 9) + 7
mod2 = 998244353
        
def inp(): return stdin.readline().strip()
def iinp(): return int(inp())
def out(var, end="\n"): stdout.write(str(var)+"\n")
def outa(*var, end="\n"): stdout.write(' '.join(map(str, var)) + end)
def lmp(): return list(mp())
def mp(): return map(int, inp().split())
def smp(): return map(str, inp().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(m, val) for j in range(n)]
def remadd(x, y): return 1 if x%y else 0
def ceil(a,b): return (a+b-1)//b
  
def isprime(x):
    if x<=1: return False
    if x in (2, 3): return True
    if x%2 == 0: return False
    for i in range(3, int(sqrt(x))+1, 2):
        if x%i == 0: return False
    return True
 
s = inp()
b = 0
l = len(s)
c = 0
for i in range(l):
    if s[i]=='0':
        if c!=0: b += pow(2, l-1-i)
    elif s[i]=='1': b += pow(2, l-1-i)
    else: 
        b += pow(2, l-1-i)
        c = 1
print(b)