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.
import java.io.*;
import java.util.*;


public class  zz{
	static long[][]memo;
	static char[]in;
	static long dp(int i,int iss) {
		if(i==in.length) {
			return 1l;
		}
		if(memo[i][iss]!=-1)return memo[i][iss];
		if(iss==0) {
			if(in[i]=='0') {
				return memo[i][iss]=dp(i+1,iss);
			}
			if(in[i]=='1')
				return memo[i][iss]=dp(i+1,1)+dp(i+1,0);
			
		}
		return memo[i][iss]=2l*dp(i+1,1);
	}
    public static void main(String[] args) throws IOException{
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        in=sc.nextLine().toCharArray();
        if(in.length==1) {
        	pw.println(1);
        	pw.flush();return;
        }
        long ans=0;
        for(int i=1;i<in.length;i++) {
        	ans+=(1l<<(i-1));
        }
        memo=new long[in.length+1][2];
        for(long[]x:memo)Arrays.fill(x,-1);
        if(in[0]>'1') {
        	pw.println(ans+dp(1,1));
        }
        else
        	pw.println(ans+dp(1,0));
        pw.flush();
    }
	static class MScanner 
	{
	    StringTokenizer st;
	    BufferedReader br;
 
	    public MScanner(InputStream s){    br = new BufferedReader(new InputStreamReader(s));}
 
	    public String next() throws IOException 
	    {
	        while (st == null || !st.hasMoreTokens()) 
	            st = new StringTokenizer(br.readLine());
	        return st.nextToken();
	    }
 
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    
	    public long nextLong() throws IOException {return Long.parseLong(next());}
 
	    public String nextLine() throws IOException {return br.readLine();}
	    
	    public double nextDouble() throws IOException
	    {
	        String x = next();
	        StringBuilder sb = new StringBuilder("0");
	        double res = 0, f = 1;
	        boolean dec = false, neg = false;
	        int start = 0;
	        if(x.charAt(0) == '-')
	        {
	            neg = true;
	            start++;
	        }
	        for(int i = start; i < x.length(); i++)
	            if(x.charAt(i) == '.')
	            {
	                res = Long.parseLong(sb.toString());
	                sb = new StringBuilder("0");
	                dec = true;
	            }
	            else
	            {
	                sb.append(x.charAt(i));
	                if(dec)
	                    f *= 10;
	            }
	        res += Long.parseLong(sb.toString()) / f;
	        return res * (neg?-1:1);
	    }
	    
	    public boolean ready() throws IOException {return br.ready();}
 
 
	}
}