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.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        solve();
    }

    static void solve() {
        int n = nextInt();
        String a = "";
        a += n;
        int m = a.length();
        long res = 0;
        long min = 0;
        int max = 0;
        for (int i = 0; i < m - 1; i++) {
            min *= 10;
            min += 9;
            max *= 10;
            max += 1;
            res += Math.pow(2, i);
        }
        max *= 10;
        max += 1;
        /*int start = 0;
        if (n > min && n <= max) {
            if (max - n < n - min) {
                
            }
        }*/
        max = Math.min(n, max);
        for (int i = max; i > min; i--) {
            if (check(i)) {
                res++;
            }
        }
        System.out.println(res);
    }

    static boolean check(int x) {
        do {
            int mod = x % 10;
            x /= 10;
            if (mod > 1) {
                return false;
            }
        } while (x > 0);
        return true;
    }

    /*****************************************************************
     ******************** BASIC READER *******************************
     *****************************************************************/

    static InputStream is = System.in;
    static private byte[] inbuf = new byte[1024];
    static private int lenbuf = 0, ptrbuf = 0;

    static private int readByte() {
        if (lenbuf == -1)
            throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0)
                return -1;
        }
        return inbuf[ptrbuf++];
    }

    static private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    static private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b))
            ;
        return b;
    }

    static private double nextDouble() {
        return Double.parseDouble(nextString());
    }

    static private char nextChar() {
        return (char) skip();
    }

    static private String nextString() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    static private char[] nextString(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    static private int[][] nextMatrix(int n, int m) {
        int[][] map = new int[n][];
        for (int i = 0; i < n; i++)
            map[i] = nextAi(n);
        return map;
    }

    static private int[] nextAi(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    static private Integer[] nextAI(int n) {
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    static private int nextInt() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
            ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    static private long nextLong() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
            ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }
}
