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.*;
import static java.lang.Math.*;

public class ProblemC_09 {
    
    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");
    
    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }
    
    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }
    
    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }
    
    long readLong() throws IOException{
        return Long.parseLong(readString());
    }
    
    public static void main(String[] args){
        new ProblemC_09().run();
    }
    
    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
    
    int[] tenPows;
    
    void solve() throws IOException{
        long n = readLong();
        int x = (int)floor(log(n) / log(10) + 1e-3) + 1;
        tenPows = new int[x];
        tenPows[0] = 1;
        for (int i = 1; i < x; i++){
            tenPows[i] = tenPows[i-1]*10;
        }
        long count = 0;
        int k = 2;
        count += f(n, x, k) - 1;
        out.print(count);
    }
    
    long binpow(long a, int n){
        if (n == 0){
            return 1;
        }
        if ((n & 1) == 0){
            long b = binpow(a, n/2);
            return b*b;
        }else{
            return binpow(a, n-1)*a;
        }
    }
    
    long f(long n, int x, int k){ //Кол-во десятичных чисел, содержащих в себе цифры от 0 до k-1
        if (n == 0){
            return 1;
        }
        long b = binpow(10, x-1);
        long c = n / b;
        return (c < k? c: k)*binpow(k, x-1) + (c < k? 1: 0)*f(n % b, x-1, k);
    }
}

