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.
//package codeforces;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StreamTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Codeforces {

    //private MyScanner sc = new MyScanner(System.in);
    private MyPrinter out = new MyPrinter(System.out);

    public void solve() throws IOException {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] num = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            num[i] = Integer.parseInt(Character.toString(s.charAt(i)));
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (num[i] > 0) {
                if (num[i] > 1) {
                    for (int j = i + 1; j < s.length(); j++) {
                        num[j] = 1;
                    }
                }
                num[i] = 1;
            }
        }
        int all = 0;
        for (int i = 0; i < s.length(); i++) {
            all += num[i] * Math.pow(2, s.length() - 1 - i);
        }
        System.out.println(all);
    }

    public static void main(String[] args) throws IOException {
        Codeforces cf = new Codeforces();
        cf.solve();
        cf.out.close();
    }
}

class MyScanner {

    private StreamTokenizer st;

    public MyScanner(InputStream is) {
        st = new StreamTokenizer(new BufferedReader(new InputStreamReader(is)));
    }

    public int nextInt() throws IOException {
        st.nextToken();
        return ((int) st.nval);
    }

    public double nextDouble() throws IOException {
        st.nextToken();
        return (st.nval);
    }

    public String nextString() throws IOException {
        st.nextToken();
        if (st.ttype == StreamTokenizer.TT_WORD) {
            return (st.sval);
        } else {
            return ("not found");
        }
    }
}

class MyPrinter {

    private BufferedWriter out;

    public MyPrinter(OutputStream os) {
        out = new BufferedWriter(new PrintWriter(os));
    }

    public void println(int i) throws IOException {
        out.write(Integer.toString(i));
        out.newLine();
    }

    public void println(double d) throws IOException {
        out.write(Double.toString(d));
        out.newLine();
    }

    public void println(long l) throws IOException {
        out.write(Long.toString(l));
        out.newLine();
    }

    public void println(String s) throws IOException {
        out.write(s);
        out.newLine();
    }

    public void println(char c) throws IOException {
        out.write(Character.toString(c));
        out.newLine();
    }

    public void print(int i) throws IOException {
        out.write(Integer.toString(i));
    }

    public void print(double d) throws IOException {
        out.write(Double.toString(d));
    }

    public void print(long l) throws IOException {
        out.write(Long.toString(l));
    }

    public void print(String s) throws IOException {
        out.write(s);
    }

    public void print(char c) throws IOException {
        out.write(Character.toString(c));
    }

    public void close() throws IOException {
        out.flush();
        out.close();
    }
}