Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."

<image>

The problem is: 

You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

If we sort all lucky numbers in increasing order, what's the 1-based index of n? 

Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.

Input

The first and only line of input contains a lucky number n (1 ≤ n ≤ 109).

Output

Print the index of n among all lucky numbers.

Examples

Input

4


Output

1


Input

7


Output

2


Input

77


Output

6
    import java.io.*;
    import java.util.*;
    public class swap1 {
    public static void main(String[] args) {
        InputReader s=new InputReader(System.in);
        PrintWriter p=new PrintWriter(System.out);

        int t=1;
        while(t-->0){

        String str=new String(s.nextToken());
        int x=0;
        int n=str.length();
        int ans=(1<<(n))-2;

        for (int i=0;i<n;i++) {
            if(str.charAt(n-i-1)=='7')
            {
               
                x|=1<<i;
            }
        }
        ans+=1+x;
        System.out.println(ans);

        }


        }   






        static void scan(int a[],int n,InputReader s){
            for (int i=0;i<n;i++) {
                a[i]=s.nextInt();
            }
        }

        static void print(int a[]){
            System.out.println(Arrays.toString(a));
        }

        public static boolean isPrime(long n) {
          if(n<=1)
            return false;
          if(n > 2 && (n & 1) == 0)
           return false;
         for(int i = 3; i * i <= n; i += 2)
            if (n % i == 0) 
                return false;
        return true;
    }

        private static long gcd(long number1, long number2) { 
        if(number2 == 0){ 
        return number1;
        }

        return gcd(number2, number1%number2);
        }

        private static long lcm(long a, long b)
        {
         return a * (b / gcd(a, b));
        }

        static long power(long x, long y)
        {
            if( y == 0)
            return 1;
            else if (y%2 == 0)
            return power(x, y/2)*power(x, y/2);
            else
            return x*power(x, y/2)*power(x, y/2); 
        }   





        static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
     
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
     
        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
     
        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
     
        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
     
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
     
        public String nextToken() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
     
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }
     
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    }