import java.beans.IntrospectionException;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String args[]) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int x = nextInt();
        ArrayList<Long> a = new ArrayList<>();
        for (int l = 1; l < 11; l++) {
            for (int mask = 0; mask < (1 << l); mask++) {
                String h = "";
                for (int i = 0; i < l; i++) {
                    if ((mask & (1 << i)) != 0) h += "7";
                    else h += "4";
                }
                a.add(Long.parseLong(h));
            }
            if(a.get(a.size() - 1) > x) break;
        }
        Collections.sort(a);
        int l = 0;
        int r = a.size();
        while (l + 1 < r) {
            int mid = (l + r) / 2;
            if (a.get(mid) <= x) l = mid;
            else r = mid;
        }
        System.out.println(r);
    }

    static StringTokenizer st = new StringTokenizer("");

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static BufferedReader br;

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        Scanner reader = new Scanner(System.in);
        String en = "";
        long x = reader.nextLong();
        long n = 0;
        int pow = 0;
        while (x > 0) {
            if (x % 10 == 7) {
                n += (long) Math.pow(2, pow);
            }
            pow++;
            x /= 10;
        }
        n += (long) Math.pow(2, pow);
        System.out.println(n - 1);
    }
}

import java.util.Scanner;

public class TestP1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long Num = scan.nextLong();
        System.out.println(getLuckyNumberCount(Num));
    }
    public static int getLuckyNumberCount(long inputNumber) {

        int luckyNumberCount = 0;
        if (inputNumber > (long)1000000000 || inputNumber < 4) {
            return 0;
        }
        long clone;
        int value;
        int digit = getDigit(inputNumber);
        long min;
        long max;
        for (int j = 0; j < digit; j++) {

            for (int i = 4; i <= 7;) {
                min = getMin(j, i);
                max = getMax(j, i);
                long pitch = 0;
                int pitchIndex = 1;

                for (long k = min; k <= max;) {
                    clone = k ;
                    if (clone > inputNumber)
                        break;
                    do {
                        value = (int) (clone % 10);
                        if (value != 4 && value != 7) {
                            break;
                        }
                        else {
                            clone = clone / 10;
                            if (clone == 0 || clone == 4 || clone == 7) {
                                luckyNumberCount++;
                                break;
                            }
                        }
                    }while(true);
                    k = k - pitch;
                    pitch = getPitchValue(pitchIndex);
                    pitchIndex++;
                    k = k + pitch;
                }

                if (i == 4) {
                    i = 7;
                } else {
                    break;
                }
            }
        }
        return luckyNumberCount;
    }

    public static int getDigit(long input) {
        int count = 1;
        long value = input;
        do {
            value = value / 10;
            if (value == 0) break;
            count++;
        }while(true);
        return count;
    }

    public static long getPitchValue(int pitchIndex) {
        long v = 0;
        int i = pitchIndex;
        int count = 0;
        do {
            int moc = i / 2;
            int re = i % 2;
            if (re != 0) {
                v = v + (long) (3 * Math.pow(10, count));
            }
            if (moc == 0) {
                break;
            } else {
                i = moc;
            }
            count++;
        }while(true);
        return v;
    }

    public static long getMin(int j, int i) {
        long v = 0;
        if (j == 0) {
            return i;
        }

        for (int x = 0; x <= j - 1; x++) {
            v += Math.pow(10, x) * 4;
        }
        v += Math.pow(10, j ) * i;
        return v;
    }

    public static long getMax(int j, int i) {
        long v = 0;
        if (j == 0) {
            return i;
        }

        for (int x = 0; x <= j - 1; x++) {
            v += Math.pow(10, x) * 7;
        }
        v += Math.pow(10, j ) * i;
        return v;
    }
}

import java.util.Scanner;

public class TestP1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long Num = scan.nextLong();
        System.out.println(getLuckyNumberCount(Num));
    }
    public static int getLuckyNumberCount(long inputNumber) {

        int luckyNumberCount = 0;
        if (inputNumber > (long)1000000000 || inputNumber < 4) {
            return 0;
        }
        long clone;
        int value;
        int digit = getDigit(inputNumber);
        long min;
        long max;
        for (int j = 0; j < digit; j++) {

            for (int i = 4; i <= 7;) {
                min = getMin(j, i);
                max = getMax(j, i);

                for (long k = min ; k <= max; k+=3) {
                    clone = k ;
                    if (clone > inputNumber)
                        break;
                    do {
                        value = (int) (clone % 10);
                        if (value != 4 && value != 7) {
                            break;
                        }
                        else {
                            clone = clone / 10;
                            if (clone == 0 || clone == 4 || clone == 7) {
                                luckyNumberCount++;
                                break;
                            }
                        }
                    }while(true);
                }

                if (i == 4) {
                    i = 7;
                } else {
                    break;
                }
            }
        }
        return luckyNumberCount;
    }

    public static int getDigit(long input) {
        int count = 1;
        long value = input;
        do {
            value = value / 10;
            if (value == 0) break;
            count++;
        }while(true);
        return count;
    }

    public static long getMin(int j, int i) {
        long v = 0;
        if (j == 0) {
            return i;
        }

        for (int x = 0; x <= j - 1; x++) {
            v += Math.pow(10, x) * 4;
        }
        v += Math.pow(10, j ) * i;
        return v;
    }

    public static long getMax(int j, int i) {
        long v = 0;
        if (j == 0) {
            return i;
        }

        for (int x = 0; x <= j - 1; x++) {
            v += Math.pow(10, x) * 7;
        }
        v += Math.pow(10, j ) * i;
        return v;
    }
}

import java.io.*;
import java.util.InputMismatchException;
import java.util.TreeSet;

/**
 * Created by Shreyans on 4/15/2015 at 2:45 AM using IntelliJ IDEA (Fast IO Template)
 */
//ADD PUBLIC FOR CF,TC
public class B//Tavas and Saddas (Bitmasking used)
{
    public static void main(String[] args) throws Exception
    {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        TreeSet<Long>ts=new TreeSet<Long>();
        for(long i=1;i<=9;i++)//PERFECTION. GENERATE A BINARY NUMBER 2^i+1 TO CHECK IF 0(4) AND 1(7) BOTH ARE SET for 2^i eg 1000 we can check 000,001,010,011,100,101,110,111!
        {
            for(long j=2<<i;j<2<<(i+1);j++)//PERFECTION IN ACTION BIATCH
            {
                String x="";
                for(int k=0;k<i;k++)
                {
                    if((j&(1<<k))>0)
                    {
                        x+="7";
                    }
                    else
                    {
                        x+="4";
                    }
                }
                ts.add(Long.parseLong(x));
            }
        }
        Long x=in.readLong();
        out.printLine(ts.headSet(x).size()+1);
        {
            out.close();
        }
    }

    //FAST IO
    private 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 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 readInt()
        {
            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 String readString()
        {
            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 double readDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public long readLong()
        {
            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 boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }

    private static class OutputWriter
    {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream)
        {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer)
        {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects)
        {
            for (int i = 0; i < objects.length; i++)
            {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects)
        {
            print(objects);
            writer.println();
        }

        public void close()
        {
            writer.close();
        }

        public void flush()
        {
            writer.flush();
        }
    }
}

import java.util.*;
  public class Solution{
     public static void main(String args[]){
     Scanner s=new Scanner(System.in);
     ArrayList<Long> array=new ArrayList<Long>();
     array.add((long)4);
     array.add((long)7);
     int size=array.size();
     int size1=0;
     long var=(long)40;
     long var1=(long)70;
     while(array.get(size-1)<=1000000000){

          for(int i=size1;i<size;i++){

               long x=var+array.get(i);
               array.add(x);
          }
          for(int j=size1;j<size;j++){
              long y=var1+array.get(j);
          array.add(y);
          }

          size1=size;
          size=array.size();
          var=var*10;
          var1=var1*10;
     }
          long input=s.nextLong();
          int count=1;
          for(int x=0;x<size;x++){
               if(array.get(x)==input){
                    break;
               }
               count++;

          }

     System.out.println(count);

     }

   }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solution {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.valueOf(br.readLine());
        long s = 0;
        long acc = 2;
        while (n > 0) {
            long d = n % 10;
            n = n / 10;
            s += acc - (d == 4 ? acc / 2 : 0);
            acc *= 2;
        }
        System.out.println(s);
    }
}

/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.Scanner;
public class Main
{
    static String input;
    static int lessThan;
    static void answer(String str){
        if (str.length() != 0 && Long.valueOf(str) >= Long.valueOf(input))
            return;
        lessThan++;
        answer(str + "4");
        answer(str + "7");
    }
	public static void main(String[] args) {
	    lessThan = 0;
	    Scanner sc= new Scanner(System.in);
	    input = sc.nextLine();
	    answer("");
	   System.out.println(lessThan);
	}
}

import java.util.*;

/**
 *
 * @author shehab
 */
public class Solving
  {

    static ArrayList<Long> ary = new ArrayList<Long>();

    static void luckyMaker(int l, String luck)
      {
        if (luck.length() == l)
          {

            ary.add(Long.parseLong(luck));
            return;
          }
        luckyMaker(l, luck + "4");
        luckyMaker(l, luck + "7");
      }

    public static void main(String[] args)
      {

        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();

        for (int i = 1; i <= 9; i++)
          {
            luckyMaker(i, "");
          }

        System.out.println(ary.indexOf(x) + 1);

      }

  }

import java.io.*;
import java.util.*;

public class TavvasAndSaddas {

    public static void solve(InputReader in, PrintWriter out) throws Exception {

        int n = in.nextInt();

        int ans =0;

        String str = Integer.toString(n);
        int d = str.length();

        for(int i=1;i<d;i++)
            ans+=1<<i;

        for(int i=0;i<d;i++)
        {
            if(str.charAt(i)=='7')
                ans += 1<<(d-i-1);
        }

        ans++;

        out.println(ans);

    }

    /////////////////////////////////////////////////////////

    private final static long hash(long x, long y) {
        x += offset;
        y += offset;
        return x << 32 | y;
    }

    private final static int offset = (int) 3e5;

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String nextToken() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public String nextLine() throws IOException {
            return reader.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(nextToken());
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[]args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] num=input.readLine().split("");
        long index=0;
        for(int i=1;i<=num.length;i++){
            if(num[num.length-i].equals("4")){
                index+=Math.pow(2,i-1);
            }
            else if(num[num.length-i].equals("7")){
                index+=Math.pow(2,i);
            }
        }
        System.out.println(index);

    }
}

import java.io.*;
import java.util.StringTokenizer;

public class Tawas47 {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            long n = in.nextInt();
            long digits = (long) (Math.log10(n)) + 1;
            long ans = 0;
            ans += 2 * (Math.pow(2, digits-1) - 1);
            int index = 0;
            while (n > 0) {
                int rem = (int) (n % 10);
                if (rem == 7) {
                    ans += Math.pow(2, index);
                }
                index++;
                n = n / 10;
            }
            ans += 1;
            System.out.println(ans);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String linea=br.readLine();
        int len=linea.length();
        long res;
        res=(1<<len)-1;
        for (int i=len-1, pos=0;i>=0;i--,pos++){
            if (linea.charAt(i)=='7'){
                res+=(1<<pos);
            }
        }
        System.out.println(res);
    }
}

import java.io.*;
import java.util.*;

public class Ideone {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = n + "";
        int len = s.length();
        String p = "";
       for (int i=s.length()-1; i>=0; i--) {
            if (s.charAt(i) == '4') {
                p = '0' + p;
            }
            else {
                p = '1' + p;
            }
        }
      // System.out.println(p);
        int x = Integer.parseInt(p,2);
        int prev = 0;
        for (int i=1; i<len; i++) {
            prev = prev + (int) Math.pow(2,i);
        }
        int ans = x+1+prev;
        System.out.println(ans);
	}
}

import java.io.*;
import java.util.*;
public final class tavas_and_sd
{
	static Scanner sc=new Scanner(System.in);
	static PrintWriter out=new PrintWriter(System.out);
	static long maxn=(long)Math.pow(10,3)+500;

	public static void main(String args[]) throws Exception
	{
		long n=sc.nextLong();
		List<Long> list=new ArrayList<Long>();
		for(long i=0;i<=maxn;i++)
		{
			String s1=Long.toBinaryString(i);
			String s2=Long.toBinaryString(i);
			s1=s1.replaceAll("1","4");
			s1=s1.replaceAll("0","7");
			s2=s2.replaceAll("1","7");
			s2=s2.replaceAll("0","4");
			long l1=Long.parseLong(s1);
			long l2=Long.parseLong(s2);
			if(!list.contains(l1))
			{
				list.add(l1);
			}
			if(!list.contains(l2))
			{
				list.add(l2);
			}
		}
		Collections.sort(list);
		out.println(list.indexOf(n)+1);
		out.close();
	}
}

import java.util.*;
public class Taddas {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = null;

        sc = new Scanner(System.in);

        int num=sc.nextInt();

        int n=num;
        int dig=0;

        while(n>0) {
        	n/=10;
        	dig++;

        }

        int Pos=0;

        Pos=(int) (2*(Math.pow(2,dig-1)))-2;

        System.out.println(Ans(num,Pos+1,dig));

	}

	public static int Ans(int num, int Pos, int dig) {

		if(dig==0) return Pos;

		int d=num/(int)Math.pow(10,dig-1);

		if(d==4) {

			num=num%(int)Math.pow(10,dig-1);
			return Ans(num,Pos,dig-1);
		}

		else {

			Pos+=(int)Math.pow(2,dig-1);

			num=num%(int)Math.pow(10,dig-1);

			return Ans(num,Pos,dig-1);

		}

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * @author mohanad
 *
 */
public class P25_Div2_535B {

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	static List<Integer> list = new LinkedList<>();
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(bf.readLine());
//		System.out.println(solv(n));
		solv2(0, n);
		Collections.sort(list);
		System.out.println(list.indexOf(n));

	}

	static void solv2(long curr , int n){

		if (curr>n){
			return ;
		}
		 list.add((int)curr);
		 solv2(curr*10+4, n);
		 solv2(curr*10+7, n);
	}

    static long solv (int n){

		List<Long> list = new LinkedList<>();
		list.add((long) 0);
		int i = 0;
		while (true){
			Long a=list.remove(0);
			if (a==n){
				return i;
			}
			list.add(a*10+4);
			list.add(a*10+7);
			++i;
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class B {
    static ArrayList<Integer> perm = new ArrayList<Integer>();

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        st = new StringTokenizer("");
        sb = new StringBuilder();

        gen();
        int x = nxtInt();

        System.out.println( search(x) );
    }//end main.

    static void gen(){
        perm.add(4);
        perm.add(7);
        int counter  = 1;
        while( counter < 9 ){

                //4 or 7;
                int x = (int) Math.pow(2, counter);

                int size = perm.size();
                for( int i =0 ;i < 2; i++){
                    for( int j = size - x ; j < size; j++ ){

                            int get = perm.get(j);
                            get += ( perm.get(i) * (int)Math.pow(10, counter));
                            perm.add( get );

                    }//end for.
                }

            counter++;
        }

    }//end for i.

static int search( int key){
        for( int i = 0;i < perm.size();i++){
            if( perm.get(i) == key){
                return i+1;
            }
        }
        return -1;
    }//end method.

    static BufferedReader br;
    static StringTokenizer st;
    static StringBuilder sb;
    static PrintWriter out;

    static String nxtTok() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null)
                return null;
            st = new StringTokenizer(s.trim());
        }
        return st.nextToken();
    }

    static int nxtInt() throws IOException {
        return Integer.parseInt(nxtTok());
    }

    static long nxtLng() throws IOException {
        return Long.parseLong(nxtTok());
    }

    static double nxtDbl() throws IOException {
        return Double.parseDouble(nxtTok());
    }

    static int[] nxtIntArr(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nxtInt();
        return a;
    }

    static long[] nxtLngArr(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nxtLng();
        return a;
    }

    static char[] nxtCharArr() throws IOException {
        return nxtTok().toCharArray();
    }
}//end class.

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

public class Solution
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int n =  sc.nextInt();
        Stack<Integer> st = new Stack<>();
        int ans = 0;
        int i=0;
        int uptonow = 0;
        if(n==4)
        System.out.println(1);
        else if(n==7)
         System.out.println(2);
         else
{
        while(n>0)
        {
            uptonow = uptonow + ((int)Math.pow(2,i));
            //System.out.println(uptonow);
            int rem = n%10;
            if(rem==4)
            st.push(0);
            else
            st.push(1);
            n=n/10;
            i++;

        }
       // System.out.println(uptonow);
        int j=st.size()-1;
       // System.out.println(j);
        while(!st.empty())
        {
            int k = st.pop();
           // System.out.println(ans);
           ans=ans+k*((int)Math.pow(2,j));
           j--;
        }
        System.out.println(uptonow+ans);
}
    }
}

import java.util.Scanner;

public class TavasAndSaddas {

	static long find(long n) {
		int count = 0;
		long ans = 1;

		while (n > 0) {
			long rem = n % 10;
			if (rem == 7) {
				ans = ans + (long) (Math.pow(2, count));
			}
			n = n / 10;
			count++;
		}

		long ans2 = 0;
		for (int i = 1; i < count; i++) {
			ans2 = ans2 + (long) Math.pow(2, i);
		}

		return ans2 + ans;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		System.out.println(find(n));
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package javaprogrammes;
import java.util.Scanner;
/**
 *
 * @author SRISHTY RANI
 */
public class TavasAndSaddas {
    public static void main(String args[]){
  Scanner sc=new Scanner(System.in);
  String str=sc.next();
  int n;
  char[] arr=str.toCharArray();
  n=arr.length;
  //if(n>=2){
  int count=0;
  for(int i=n-1;i>0;i--){
  count+=(1<<i);
  }
  int a=0;
  while(a<n){
  if(arr[a]=='4'){
  a++;}
  else{
  int b=(n-a)-1;
  count+=1<<b;
  a++;
  }}
  System.out.println(count+1);
  }}

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

/**
 * Created by peacefrog on 11/9/15.
 * Time : 10:22 PM
 */

public class C {
	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	PrintWriter out;
	long timeBegin, timeEnd;

	public void runIO() throws IOException {
		timeBegin = System.currentTimeMillis();

		InputStream inputStream;
		OutputStream outputStream;

		if (ONLINE_JUDGE) {
			inputStream = System.in;
			Reader.init(inputStream);
			outputStream = System.out;

			out = new PrintWriter(outputStream);

		} else {
			inputStream = new FileInputStream("/home/peacefrog/Dropbox/IdeaProjects/Problem Solving/input");
			Reader.init(inputStream);
			out = new PrintWriter("output.txt");
		}

		solve();

		out.flush();
		out.close();
		timeEnd = System.currentTimeMillis();

		System.err.println("Time = " + (timeEnd - timeBegin));

	}

	/*
	 * Start Solution Here
	 */

	private void solve() throws IOException {
		long n = Reader.nextLong(); //This Variable default in Code Templete
		ArrayList<Long> lucky = new ArrayList<>();

		ArrayList<Long> temp = new ArrayList<>();

		temp.add(4L);
		temp.add(7L);

		while (!temp.isEmpty())
		{
			long top = temp.remove(0);
			if (top <= 1E9)
			{
				lucky.add(top);
				temp.add(top*10+4);
				temp.add(top*10+7);
			}
		}

		Collections.sort(lucky);
		System.out.println(lucky.indexOf(n)+1);
	}

	public static void main(String[] args) throws IOException {

		new C().runIO();
	}

	static class Reader {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		/**
		 * call this method to initialize reader for InputStream
		 */
		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		/**
		 * get next word
		 */
		static String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		static String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "";
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}

}

import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    int calc(String num) {
        char c = num.charAt(0);
        int m;
        if(c == '4')
            m = 1;
        else
            m = 2;
        int l = num.length();
        if(l == 1) {
            return m;
        } else {
            return (m-1)*(1<<l-1) + calc(num.substring(1));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.readLine();

        out.println(((1<<s.length())-2) + calc(s));
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

}

import java.util.*;

public class B {

	public static void main(String[] args) {

		Scanner qwe = new Scanner(System.in);

		ArrayDeque<Long> sofar = new ArrayDeque<Long>();

		sofar.add(4l);
		sofar.add(7l);

		ArrayList<Long> lucky = new ArrayList<Long>();
		while(!sofar.isEmpty()){
			long cur = sofar.poll();
			if(cur <= 1e9){
				lucky.add(cur);
				sofar.add(cur*10+4);
				sofar.add(cur*10+7);
			}
		}

		Collections.sort(lucky);

		System.out.println(lucky.indexOf(qwe.nextLong())+1);

		qwe.close();
	}

}

import java.util.*;
/**
 *
 * @author Archit
 */
public class tavasandSadda {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n1= n/10;
        int x = 1;
        int ans=0;
        while(n1!=0){
            x=x<<1;
            ans+=x;
            n1/=10;
        }
        String s = String.valueOf(n);
        String s1 = "";
        x = 0;
        for(int i =0;i<s.length();i++){
            x<<=1;
            if(s.charAt(i)=='7') x+=1;
        }
        System.out.println(x+ans+1);

    }
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author debian-lover
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int score = input.nextInt();
        int counter = 0;
        String str = String.valueOf(score);

        for (int i = 0; i < str.length(); i++) {

            if(str.charAt(i)=='4'){

                counter += Math.pow(2,str.length()-i-1);

            }
            if(str.charAt(i)=='7')
            {
                counter += Math.pow(2,str.length()-i);
            }
        }
        System.out.println(counter);
    }

}

import java.util.*;
/**
 *
 * @author Archit
 */
public class tavasandSadda {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n1= n/10;
        int x = 1;
        int ans=0;
        while(n1!=0){
            x=x<<1;
            ans+=x;
            n1/=10;
        }
        n1=n;
        x = 1;
        while(n1!=0){
            if(n1%10==7)ans+=x;
            x<<=1;
            n1/=10;
        }
        System.out.println(ans+1);

    }
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Euler {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		String str = in.next();
		int n = str.length();
		int ans =  ((int)Math.pow(2, str.length()) ) - 2;
		int x = 1;

		for (int i = 0; i < str.length(); i++) {

			if (str.charAt(i) == '4') {
				continue;
			}
			if (str.charAt(i) == '7') {
				x += ((int)Math.pow(2, n - 1 - i));
			}

		}

		//if (str.charAt(n - 1) == '7') ans++;

		ans += x;

		System.out.println(ans);

	}
}

import java.util.*;
public class playnum{
	static ArrayList<Long> al = new ArrayList<>();
	public static void main(String s[]){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		compute(0);
		Collections.sort(al);
		for(int i=1;i<=al.size();i++){
			if(al.get(i)==n){
				System.out.println(i);
				break;
			}
		}
	}

	public static void compute(long x){
		if(x>1000000009)
			return;

		al.add(x);
		compute((x*10)+4);
		compute((x*10)+7);
		return;
	}
}

import java.util.*;

public class Main
{
    static int max = Integer.MAX_VALUE;
    static ArrayList<Integer> val = new ArrayList<Integer>();

    public static void main(String[] args)
    {

        // 67 19 20 30

        Scanner s = new Scanner(System.in);
        int num = s.nextInt(),c=0,v;

        Queue<Integer> queue = new LinkedList<Integer>();
        queue.add(0);

        while(true)
        {

            v = queue.peek();

            v = v*10+4;
            c++;

            if(num==v)
            {
                System.out.println(c);
                break;
            }

            queue.add(v);

            v = queue.remove();

            v = v*10+7;
            c++;

            if(num==v)
            {
                System.out.println(c);
                break;

            }

            queue.add(v);

        }//while

    }//maim

}//class

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main
{
	public int bfs(int n)
	{
		Queue<Integer> q = new LinkedList<Integer>();
		q.offer(0);
		HashSet<Integer> set = new HashSet<Integer>();
		while(!q.isEmpty())
		{
			int x = q.poll();
			if(10L * x + 4 <= n)
			{
				set.add(10 * x + 4);
				q.offer(10 * x + 4);
			}
			if(10L * x + 7 <= n)
			{
				set.add(10 * x + 7);
				q.offer(10 * x + 7);
			}
		}
		return set.size();
	}

	public void foo()
	{
		MyScanner scan = new MyScanner();
		int n = scan.nextInt();
		System.out.println(bfs(n));
 	}

	public static void main(String[] args)
	{
		new Main().foo();
	}

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read()
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try
	            {
	                numChars = bis.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 double nextDouble()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-')
	        {
	            sgn = -1;
	            c = read();
	        }
	        double res = 0;
	        while (!isSpaceChar(c) && c != '.')
	        {
	            if (c == 'e' || c == 'E')
	            {
	            	return res * Math.pow(10, nextInt());
	            }
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c & 15;
	            c = read();
	        }
	        if (c == '.')
	        {
	            c = read();
	            double m = 1;
	            while (!isSpaceChar(c))
	            {
	                if (c == 'e' || c == 'E')
	                {
	                	return res * Math.pow(10, nextInt());
	                }
	                if (c < '0' || c > '9')
	                {
	                	throw new InputMismatchException();
	                }
	                m /= 10;
	                res += (c & 15) * m;
	                c = read();
	            }
	        }
	        return res * sgn;
	    }

	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c)
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class b_299 {
    static ArrayList<Long> list;

    public static void generate(long n, int len) {
        if (len == 9)
            return;
        long temp = n * 10 + 4;
        list.add(temp);
        generate(temp, len + 1);
        temp = n * 10 + 7;
        list.add(temp);
        generate(temp, len + 1);
    }

    public static void main(String[] args) {
        list = new ArrayList<Long>();
        generate(0, 0);
        Collections.sort(list);
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        int res = 0;
        for (int i = 0; i < list.size(); i++) {
            if (n == list.get(i)) {
                res = i + 1;
                break;
            }
        }
        System.out.println(res);
    }
}

import java.util.Scanner;

public class Solution{

	public static int func(int n) {
		String num = Integer.toString(n);
		int past = 1;
		if(num.charAt(num.length() - 1) == '7') past = 2;
		for(int i = (num.length()-2); i >= 0; i--) {
			char c = num.charAt(i);
			if(c == '7') past += (1 << (num.length()-1-i));
		}

		for(int i = (num.length() - 1); i >= 1; i--) {
			past += (1 << i);
		}

		return past;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(func(n));
	}
}

import java.io.*;
import java.util.*;

public class Prob {
    static BufferedReader in;

    public static void solve() throws IOException{
        int n = nextInt();
        Queue<Long> q = new ArrayDeque<>();
        q.add(4L);
        q.add(7L);

        int count = 0;
        while (!q.isEmpty()){
            long curr = q.poll();
            count++;
            if(curr == n)
                break;
            if(curr > Math.pow(10,9))break;
            q.add(curr*10+4);
            q.add(curr*10+7);
        }

        System.out.println(count);

    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());

    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

    static Integer[] nextLinesArray(int n) throws IOException {
        StringTokenizer st;
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(in.readLine().trim());
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}

import java.util.*;
import java.lang.*;
public class go
{
    // A function to print all prime factors of a given number n
long gcd ( long a, long b )
{
  if ( a==0 ) return b;
  return gcd ( b%a, a );
}
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int k  = s.length();
        int r = (int)Math.pow(2,k)-2;
        int[] ar = new int[k];
        for(int i=0;i<k;i++)
        {
            if(s.charAt(i)=='4'){ar[k-1-i]=0;}
            else{ar[k-1-i]=1;}
        }
        int sum=0;
        for(int i=0;i<k;i++)
        {
            sum+=(ar[i])*(int)Math.pow(2,i);
        }
        sum++;
        System.out.println(r+sum);
}
}

import java.util.*;
import java.io.*;

 public class Param
{

      public static  void main( String[]args)
    {
    Scanner param = new Scanner(System.in);
   int n=param.nextInt();
   int r=0;
   int count=0;
   ArrayList<Integer>l1=new ArrayList<Integer>();
  while(n!=0){
     r=n%10;
     l1.add(r);
     count++;
     n=n/10;
  }
  int sum=0;
  if(count==1){
     sum=0;
  }
  else{
  for(int i=1;i<count;i++){
  sum+=(int)Math.pow(2,(i));

  }
  }
  StringBuilder sb=new StringBuilder();
  for(int i=l1.size()-1;i>=0;i--){
     if(l1.get(i)>4){
        sb.append("1");
     }
     else{
       sb.append("0");
     }
  }
  String y=sb.toString();

  for(int i=y.length()-1;i>=0;i--){
     if(y.charAt(i)=='1'){
        sum+=(int)Math.pow(2,(y.length()-1)-i);
     }
  }
  System.out.println(sum+1);
}
}

import java.util.*;

/**
 *
 * @author greggy
 */
public class TavasAndSaddas {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int ans = 1;
        String lucky = in.nextLine();
        int n = lucky.length();
        for (int i = 1; i < n; i++) {
            ans += (1 << i);
        }
        lucky = lucky.replaceAll("4", "0");
        lucky = lucky.replaceAll("7", "1");
        ans += Integer.parseInt(lucky, 2);

        System.out.println(ans);

    }

}

import java.util.Scanner;

public class Tavas_and_Saddas{
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.nextLine();
        long first_part = 2*((1<<(str.length()-1))-1);
        int i = str.length()-1;
        int j = 0;
        long second_part = 0;
        while(i >= 0){
            if(str.charAt(i) == '7'){
                second_part += (1<<j);
            }
            j++;
            i--;
        }

        System.out.println(first_part+second_part+1);

        s.close();
    }
}

//package pkg535b;
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        int n=str.length();
        long ans=0;
        long temp=0;
        long m=1;
        for(int i=n-1;i>=0;i--)
        {
            if(str.charAt(i)=='7')
            {
                temp=temp+2*m;
            }
            else
            {
                temp=temp+m;
            }
            m=m*2;

        }
        int i=n-1;
      //  while(i>0)
        {
           // ans=ans+(long)Math.pow(2, i);
            i--;
        }
        System.out.println(ans+temp);
    }

}

import java.util.*;
import java.lang.*;

public class Sol{

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		String str = Integer.toString(num);
		int len = str.length();
		int ans=0,temp=2;

		for(int i=1;i<len;i++){
			ans+=temp;
			temp*=2;
		}
		temp=0;
		String str1="";
	 	while(num!=0){
			if((num%10)==4) str1+="0";
			else str1+="1";
			num/=10;
		}
		StringBuffer sb = new StringBuffer(str1);
		sb.reverse();
		ans+= Integer.parseInt(sb.toString(),2);
		ans+=1;
		System.out.println(ans);

	}

}

import java.io.IOException;
import java.util.Scanner;
public class ch {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String st = in.next();
        char[] array = st.toCharArray();
        int kol = 0;
        for (int i = 0; i < array.length; i++)
            if (array[i] == 55) array[i] = 50;
            else array[i] = 49;
            for (int i = 0; i < array.length; i++) kol += (array[i] - 48) * Math.pow(2, array.length - i-1);
            System.out.println(kol);
    }
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder s = new StringBuilder(scanner.next());
        int n = s.length();
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '4') s.setCharAt(i, '0');
            else s.setCharAt(i, '1');
        }
        int ans = Integer.parseInt(s.toString(), 2) + 1;
        for (int i = 1; i <= n-1; i++) {
            ans += Math.pow(2, i);
        }
        System.out.println(ans);
    }
}

import java.util.Scanner;

public class Codeforces535B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int cur = in.nextInt();
        int poisk = cur;
        int rasr = 0;
        int kol = 0;
        int now = 0;
        int plus = 1;
        while (poisk != 0) {
            rasr++;
            kol += Math.pow(2, rasr);
            now += plus * 4;
            plus *= 10;
            poisk /= 10;
        }
        double go =kol- Math.pow(2, rasr);
        StringBuilder s = new StringBuilder(Integer.toString(now));
        StringBuilder need = new StringBuilder(Integer.toString(cur));
        if (need.length() == 1) {
            if (need.charAt(0) == '4') {
                System.out.println(1);
            } else {
                System.out.println(2);
            }
        } else {
            for (int j = 0; j < s.length() - 1; j++) {
                if (s.charAt(j) == need.charAt(j)) {
                    continue;
                } else {
                    go += Math.pow(2, s.length() - j - 1);
                }
                if (go == kol) {
                    break;
                }
            }
            if (go==kol) {
                System.out.println(kol);
            } else {
                if (s.charAt(s.length() - 1) == need.charAt(s.length() - 1)) {
                    System.out.println((int)(go+1));
                } else {
                    System.out.println((int)(go + 2));
                }
            }
        }
    }
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String n = sc.nextLine().replaceAll("4", "0").replaceAll("7", "1");
        int ans = Integer.parseInt(n, 2) + 1;
        for(int i = 1; i < n.length(); ++i)
            ans += (int)Math.round(Math.pow(2, i));

        System.out.println(ans);

    }
}

import java.util.*;
public class CF535B {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		long ans = 0;
		for(int i = 0; i < s.length(); i ++)
		{
			if(s.charAt(i) == '7')
				ans += Math.pow(2,  s.length() - i);
			else
				ans += Math.pow(2, s.length() - i - 1);
		}
		System.out.println(ans);
	}
}

import java.util.*;

/**
 * Created by smalex on 26/10/15.
 */
public class P535B {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    long a = scanner.nextLong();
    long res = 0;
    long mul = 1;
    while (a > 0) {
      if (a % 10 == 4) {
        res += mul;
      } else {
        res += 2 * mul;
      }
      a /= 10;
      mul *= 2;
    }
    System.out.println(res);
  }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int num;

		Scanner in=new Scanner(System.in);
		num=in.nextInt();

		question2 obj1=new question2();
		obj1.set_num(num);
		System.out.println(obj1.find_rank());

	}
}

class question2
{
	private int num=0;

	public int find_rank()
	{
		int len=find_length();

		if(len==1)
		{
			if(num==4)
				return 1;
			else
				return 2;
		}

		int low=(int)(Math.pow((double)2,(double)len)-1);
		int high=low*2;

		int temp=num;

		while(len>0)
		{
			int x=(int)(Math.pow((double)10,(double)len-1));

			if(temp/x==4)
			{
				high=(low+high)/2;

			}
			else
			{
				low=(low+high)/2+1;

			}
			len--;
			temp=temp%x;
			x=x/10;

		}
		return low;
	}

	public int find_length()
	{
		int temp=num;
		int len=0;
		while(temp>0)
		{
			temp=temp/10;
			len++;
		}

		return len;
	}

	public void set_num(int a)
	{
		num=a;
	}

}

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String s = "" + n;

        String s1 = "";

        int y = 0;

        if(s.length()==1) {
            if(s.charAt(0)=='4') {
                System.out.println(1);
            }
            else {
                System.out.println(2);
            }
            return;
        }

        for(int i=1; i<s.length(); i++) {
            y += (int) Math.pow(2, i);
        }

        int ans = 0;

        int b;

        for(int i=0; i<s.length(); i++) {

            if(s.charAt(i)=='4') {
                s1 += "0";
            }
            else {
                s1 += "1";
            }
        }

        for(int i=0, j=s.length()-1; i<s.length(); i++, j--) {

            b =  (s1.charAt(i)-'0') * (int) Math.pow(2, j);

            ans += b;
        }

        System.out.println(y + ans + 1);
    }
}

import java.io.*;
import java.util.*;

public class Main {

	public static FastReader scan = new FastReader();

	public static void main(String[] args) {

		String s = scan.next();
		int n = s.length();
		int pow = (int)Math.pow(2, n);
		int ans = 0;

		for(int i=0; i<n; i++) {
			if(s.charAt(i) == '4') ans += 0;
			else ans += pow/2;
			pow /= 2;
		}

		System.out.println((int)Math.pow(2, n) - 2 + ans+1);

  }

	public static int abs(int a, int b) {return Math.abs(a - b);}

	// sieveOfEratosthenes
	public static boolean[] sieve(int n) {
		boolean[] prime = new boolean[n+1];

		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;

		for(int i=2; i*i<n; i++) {
			if(prime[i] == true) {
				for(int j=i*2; j<=n; j+=i) {
					prime[j] = false;
				}
			}
		}

		return prime;
	}

	//smallestFactor function
	public static long smallestFactor(long n) {
		int i;
		for(i=2; i*i<n; i++) {
			if(n%i == 0)
				break;
		}
		return i;
	}

	//FastReader Class
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		char[] nextChar()
		{
			return next().toCharArray();
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

public class practice {
    public static void merge(int arr[], int l, int m, int r) {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int[n1];
        int R[] = new int[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];

        int i = 0, j = 0;

        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            } else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    public static void sort(int arr[], int l, int r) {
        if (l < r) {
            int m = (l + r) / 2;

            sort(arr, l, m);
            sort(arr, m + 1, r);

            merge(arr, l, m, r);
        }
    }

    public static boolean isSubSequence(String str1, String str2, int m, int n) {
        int j = 0;
        for (int i = 0; i < n && j < m; i++)
            if (str1.charAt(j) == str2.charAt(i))
                j++;

        return (j == m);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int len = 0;
        int ans = 0;
        while(n>0){
            if (n % 10 == 7)
                ans += (1 << len);
            n /= 10;
            len++;
        }
        for (int i = 1; i < len; i++)
            ans += (1 << i);
        System.out.println(ans+1);
    }
}

import java.util.Scanner;

public class B535 {
    public static void main(String[] args){
        Scanner input= new Scanner(System.in);
        String n = input.nextLine();
        int rslt = 0;
        String number = "";
        int temp = 0;
        for(int i = 1; i <= n.length(); i++) {
            if(i == n.length()) {
                for(int l = 0; l < Math.pow(2, i); l++){
                    for(int k = i-1; k >= 0; k--) {
                        temp = (l/(int) Math.pow(2, k))%2;
                        if(temp == 0)
                            number += "4";
                        else
                            number += "7";
                    }
                    rslt++;
                    if(n.equals(number))
                        break;
                    number = "";
                }
            } else {
                rslt += Math.pow(2, i);
            }
        }
        System.out.println(rslt);
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	static ArrayList<Long>luck=new ArrayList<>();
	static long big=1000000007;
	public static void pushLuck(long num) {
		if(num>big)
			return;
		if(num!=0)
			luck.add(num);

		pushLuck(num*10+4);
		pushLuck(num*10+7);

	}

	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);

		long n =in.nextInt();
		pushLuck(0);
		Collections.sort(luck);

		System.out.println(luck.indexOf(n)+1);

}}

import java.util.*;
import java.math.*;
import java.io.*;
 public class A{
static int sum;
static int gcd(int a,int b){
if(b==0)
    return a;
return gcd(b,a%b);
}
static void getdistance(String s,String t){

    int j=0;
    for(int i=0;i<Math.max(s.length(),t.length());i++){
        sum+=Math.abs((int)((int)s.charAt(i)-(int)(t.charAt(j))));

        j++;

//System.out.println(sum);
    }

}
static ArrayList<Long>l=new ArrayList<Long>();
static void lucky(long num){
if(num>1000000007)return;
if(num!=0)
l.add(num);
lucky(num*10+7);
lucky(num*10+4);

}
public static void main(String[] args)  throws IOException

{
	InputReader scan=new InputReader(System.in);
  PrintWriter out=new PrintWriter(System.out);
int n=scan.nextInt();
lucky(0);
Collections.sort(l);

int j=1;

for(Long i:l){
if(i==n)
    out.println(j);
j++;
}
 out.close();

}

 static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int arraySize) {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++) {
                array[i] = nextInt();
            }

            return array;
        }

    }
static class pair implements Comparable<pair>{
	int i;
	int j;
pair(int i,int j){
	this.i=i;
	this.j=j;
} public int compareTo(pair o) {
        return i - o.i;
    }

}

}

 import java.util.*;

public class ListCollectionTest {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String num = in.nextLine();
        int numberPoisc = (int) (Math.pow(2,num.length())-2);
        num = num.replace('4','0').replace('7','1');
        numberPoisc += Integer.parseInt(num,2)+1;
        System.out.println(numberPoisc);
            }
}

import java.util.Scanner;

public class TavasAndSaDDas {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n==4)
			System.out.println("1");
		else if(n==7)
			System.out.println("2");
		else{
			int c = 1;
			int ans = 0;
			while(n>0){
				if(n%10 == 4){
					ans += c;
				}
				else ans = ans+2*c;
				n = n/10;
				c = c*2;
			}

			System.out.println(ans);

		}

	}

}

import java.util.*;

public class B {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        String n = in.next();

        int res = 0;
        for (int i = 0; i < n.length(); i++) {
            if (n.charAt(n.length() - 1 - i) == '4') {
                res += Math.pow(2, i);
            }
            else {
                res += Math.pow(2, i + 1);
            }
        }

        System.out.println(res);
    }

}

import java.util.*;
import java.lang.*;
import java.io.*;

public class Tavas {
    void solve2(){
        Scanner in=new Scanner(System.in);
        long num=in.nextInt();

        PriorityQueue pq=new PriorityQueue();
        pq.add((long)4);
        pq.add((long)7);
        int n=0;
        while(!pq.isEmpty()){
            Long fornt=(Long) pq.remove();
            Long temp=(long) 0;
            if(fornt<=num){
                temp=fornt*10+4;
                pq.add(temp);
                temp=fornt*10+7;
                pq.add(temp);
                n++;

            }
        }
        System.out.println(n);
    }
    void solve(){
        Scanner in=new Scanner(System.in);
        int num=in.nextInt();
        int n=0;

        for(int i=3;i<=num;i++){
            if(Judge(i)==true){
                n+=1;
            }
        }
        System.out.println(n);

        }

    static boolean Judge(int num){
        int ge=0;
        while(num!=0){
            ge=num%10;
            if(ge!=4 && ge!=7){
                return false;
            }
            num=num/10;
        }
        return true;
    }
    public static void main(String[] args) {
        new Tavas().solve2();

    }

}

import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    String number = input.next();
    int sum=0;
    for(int x=0;x<number.length();x++){

    sum= number.substring(x,x+1).equals("4") ? sum+(int)Math.pow(2,number.length()-x-1) :sum+(int)Math.pow(2,number.length()-x-1)*2;

    }
    System.out.println(sum);
  }
}

import java.util.*;

public class Code {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long mas[] = new long[20000];
        mas[0] = 4;
        mas[1] = 7;
        int indexByAdd = 1;
        int index = 0;
        if (n == 4) {
            System.out.println(1);
            return;
        }
        if (n == 7) {
            System.out.println(2);
            return;
        }
        while (mas[index] != n) {
            indexByAdd++;
            mas[indexByAdd] = mas[index] * 10 + 4;
            indexByAdd++;
            mas[indexByAdd] = mas[index] * 10 + 7;
            index++;
        }
        if (mas[index] == n) {
            System.out.println(index+1);
        } else {
            System.out.println(index);
        }
    }
}

import java.util.Scanner;

public class TavasandSaDDas {
	public static void main(String[]args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.nextLine();
		int sum=0;
		for(int i=1;i<s.length();i++) {
			sum+=(1<<i);
		}
		int i=sum+1;
		int j=sum+(1<<s.length());
		int border=0;
		while(i!=j && border<s.length()) {
			int mid=(i+j)/2;
			if(s.charAt(border)=='4') {
				j=mid;
			}
			else {
				i=mid;
			}
			border++;
		}
		System.out.println(j);
	}
}

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void swap(int[] a,int p1,int p2){
		int t = a[p1];
		a[p1] = a[p2];
		a[p2] = t;
	}

	public static void main(String[] args){
		Scanner input = new Scanner(System.in);

		int n = input.nextInt();
		int a[] = new int[20];

		int l;
		for(l = 0; n>0; l++){
			a[l] = n % 10;
			n /= 10;
		}
		for(int i = 0; i < l>>1; i++){
			swap(a, i, l - i -1);
		}

		int ans = 0;
		for(int i = 1; i <= l - 1; i++){
			ans += 1<<i;
		}
		for(int i = 0; i < l; i++){
			if(a[i] == 7) ans += 1<<(l-i-1);
		}
		ans += 1;

		System.out.println(ans);

		input.close();
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    public static void main (String[] args) {
        FastReader in = new FastReader(System.in);

        int n = in.nextInt();

        int d = 0;
        int b = 0;

        while (n != 0) {
            b = b | (n % 10 == 7 ? 1 : 0) << d;

            d++;
            n /= 10;
        }

        System.out.println((long) Math.pow(2, d) - 1 + b);
    }
}

class FastReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        this.reader = new BufferedReader(new InputStreamReader(stream));
        this.tokenizer = new StringTokenizer("");
    }

    public boolean hasNext() {
        return ensureTokens();
    }

    public String next() {
        return  ensureTokens() ? tokenizer.nextToken() : null;
    }

    private boolean ensureTokens() {
        while(!tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (Exception e){
                return false;
            }
        }
        return true;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (Exception e) {
            return null;
        }
    }

    public char[] nextCharArray() {
        return nextLine().toCharArray();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public int[] nextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    public int[] nextIntArrayOnLine() {
        String line = nextLine();
        String[] tokens = line.split(" ");
        int[] array = new int[tokens.length];
        for (int i = 0; i < tokens.length; i++) {
            array[i] = Integer.parseInt(tokens[i]);
        }
        return array;
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public long[] nextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextLong();
        }
        return array;
    }

    public float nextFloat() {
        return Float.parseFloat(next());
    }

    public float[] nextFloatArray(int size) {
        float[] array = new float[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextFloat();
        }
        return array;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public double[] nextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextDouble();
        }
        return array;
    }

    public short nextShort() {
        return Short.parseShort(next());
    }

    public short[] nextShortArray(int size) {
        short[] array = new short[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextShort();
        }
        return array;
    }

    public BigDecimal nextBigDecimal() {
        return new BigDecimal(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

class FastWriter {
    private final PrintWriter printWriter;

    public FastWriter(OutputStream stream) {
        printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public FastWriter(Writer writer) {
        printWriter = new PrintWriter(writer);
    }

    public void close() {
        printWriter.close();
    }

    public void print(boolean element) {
        printWriter.print(element);
    }

    public void print(char[] element) {
        printWriter.print(element);
    }

    public void print(double element) {
        printWriter.print(element);
    }

    public void print(float element) {
        printWriter.print(element);
    }

    public void print(int element) {
        printWriter.print(element);
    }

    public void print(long element) {
        printWriter.print(element);
    }

    public void print(String element) {
        printWriter.print(element);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                printWriter.print(' ');
            }
            printWriter.print(objects[i]);
        }
    }

    public void println(boolean element) {
        printWriter.println(element);
    }

    public void println(char[] element) {
        printWriter.println(element);
    }

    public void println(double element) {
        printWriter.println(element);
    }

    public void println(float element) {
        printWriter.println(element);
    }

    public void println(int element) {
        printWriter.println(element);
    }

    public void println(long element) {
        printWriter.println(element);
    }

    public void println(String element) {
        printWriter.println(element);
    }

    public void println() {
        printWriter.println();
    }

    public void println(Object... objects) {
        print(objects);
        printWriter.println();
    }

    public void printf(String format, Object... args) {
        printWriter.printf(format, args);
    }
}

import java.util.PriorityQueue;
import java.util.Scanner;

public class B535 {
	void solve2(){
		Scanner in=new Scanner(System.in);
		long num=in.nextInt();

		PriorityQueue pq=new PriorityQueue();
		pq.add((long)4);
		pq.add((long)7);
		int n=0;
		while(!pq.isEmpty()){
			Long fornt=(Long) pq.remove();
			Long temp=(long) 0;
			if(fornt<=num){
				temp=fornt*10+4;
				pq.add(temp);
				temp=fornt*10+7;
				pq.add(temp);
				n++;

			}
		}
		System.out.println(n);
	}
	void solve(){
		Scanner in=new Scanner(System.in);
		int num=in.nextInt();
		int n=0;

		for(int i=3;i<=num;i++){
			if(Judge(i)==true){
				n+=1;
			}
		}
		System.out.println(n);

		}
	//�жϸ�λ�ǲ���4 �� 7
	static boolean Judge(int num){
		int ge=0;
		while(num!=0){
			ge=num%10;
			if(ge!=4 && ge!=7){
				return false;
			}
			num=num/10;
		}
		return true;
	}
	public static void main(String[] args) {
		new B535().solve2();

	}

}

import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner  scn = new Scanner(System.in);

   		String n = scn.nextLine();

   		long ans =0;

   		int len = n.length();

   		ans = (1<<len)-2;

   		for(int i=0,pos= len-1; i<len; i++,pos--){
   			if(n.charAt(i) == '7'){
   				ans += (1<<pos);
   			}
   		}

   		++ans;
   		System.out.println(ans);

    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class DiningTable {
    //static int dir[][]={{0,1},{0,-1},{1,0},{-1,0}};

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            OutputStream outputStream = System.out;
            PrintWriter out = new PrintWriter(outputStream);

            int i, j, u=0, v=0;

        String r = br.readLine();
        int sum=0;
        for(i=1; i<=r.length() ; i++)
            sum+=(1<<i);
        int[] ar = new int[sum+1];
        ar[0]=4;
        ar[1]=7;
        int num = Integer.parseInt(r);
        if(num==4)
        {
            out.print("1");
            out.close();
            return;
        }
        else
        if(num==7)
        {
            out.print("2");
            out.close();
            return;
        }
        int a, b=-1;
        int[] m = new int[2];
        m[0]=4;
        m[1]=7;
        int index;
        int k=2;
        int flap=0;
        StringBuilder sb = new StringBuilder("");
        for(i=1 ; i<=r.length() ; i++)
        {
            int tmp=(1<<i);
            index=0;
            a=b+1;
            b=a+tmp-1;
            int flag=0;
            for(int loop=1 ; loop<=2 ; loop++){
                    for(j=a ; j<=b ; j++)
                        {
                            String take =m[index]+""+ar[j];
                            ar[k++]=Integer.parseInt(take);
                            //out.println(ar[k-1]);
                            if(num==ar[k-1])
                            {
                                flag=1;
                                break;
                            }
                        }
                    if(flag==1)
                    {
                        flap=1;
                        break;
                    }
                index=1-index;
            }
            if(flap==1)
                break;
        }
        out.print(k);
        out.flush();
        out.close();
        }
    }

import java.util.Scanner;
public class Main1 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        String s = String.valueOf(n);

        int index=0;
        for(int i=1 ; i<=s.length() ; i++)
            if(s.charAt(s.length()-i) == '4')
            index += Math.pow(2, i-1);
            else if(s.charAt(s.length()-i) == '7')
                index += Math.pow(2, i);

        System.out.print(index);

    }

}

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class CodeForces {
    static int [] num = new int[123456];
    public static void main(String[] args)throws IOException {
        //MyScanner sc = new MyScanner(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter("output.txt");
        PrintWriter out = new PrintWriter(System.out);
        MyScanner sc = new MyScanner(System.in);
        Vector<Integer>vec = new Vector<>();
        vec.add(4);
        vec.add(7);
        for(int i = 0 ; i <600 ; i ++){

            vec.add((vec.elementAt(i)*10)+4);
            vec.add((vec.elementAt(i)*10)+7);
        }
        int n ;
        n = sc.nextInt();
        for(int i = 0 ; i < vec.size() ; i++ ){
            if(n == vec.elementAt(i)){
                out.print(i+1);
            }
        }
        out.flush();
        out.close();

    }

    static long gcd(long a, long b) { return b==0 ? a : gcd(b, a % b); }
    static long lcm(long a, long b) { return (a / gcd(a, b)) * b; }
    static class MyScanner
    {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

        public MyScanner(FileReader s) throws FileNotFoundException {	br = new BufferedReader(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 { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}

/**
 * Created by gosugdr on 4/22/15.
 */

import java.util.*;
import java.io.*;

public class A379 {
    FastScanner in;
    PrintWriter out;

    ArrayList<Long> precalc = new ArrayList<>();

    void bruteForce(long cur) {
        if (cur > Integer.MAX_VALUE) {
            return;
        }
        precalc.add(cur * 10 + 4);
        bruteForce(cur * 10 + 4);
        precalc.add(cur * 10 + 7);
        bruteForce(cur * 10 + 7);
    }

    public void solve() throws IOException {
        bruteForce(0);
        Collections.sort(precalc);
        long a = in.nextLong();
        out.println(Collections.binarySearch(precalc, a) + 1);
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] arg) {
        new A379().run();
    }
}

import java.util.*;
public final class TavasSaddas
{
	public static void main(String arg[])
	{
		Scanner br=new Scanner(System.in);
		int n=br.nextInt();
		int a=4,b=7;
		int q[]=new int[5000];
		q[0]=4;q[1]=7;
		int j=2,p=2;;
		while(n>Math.max(a,b))
		{
			q[j++]=a*10+4;
			q[j++]=a*10+7;
			q[j++]=b*10+4;
			q[j++]=b*10+7;
			a=q[p];
			b=q[p+1];
			p+=2;
		}
		int i=0;
		while(q[i]!=n)
		i++;
		System.out.print(i+1);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	static int MOD = 1000 * 1000 * 1000 + 7;

	public static void shuffleArray(int[] arr) {
		int n = arr.length;
		Random rnd = new Random();
		for (int i = 0; i < n; ++i) {
			int tmp = arr[i];
			int randomPos = i + rnd.nextInt(n - i);
			arr[i] = arr[randomPos];
			arr[randomPos] = tmp;
		}
	}

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		solve(in, out);
		out.close();
		System.exit(0);
	}

	private static void solve(InputReader in, PrintWriter out) {

		char[] s = in.next().toCharArray();
		int n = s.length;
		int val = (1 << n) - 1;
		for (int i = n - 1; i >= 0; i--) {
			if (s[i] == '4') {
				val ^= (1 << (n - 1 - i));
			}
		}
		out.print(val + (1 << n) - 1);
	}

	/*
		*
		*/
	// --------------------------------------------------------

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}

			return str;
		}
	}

}

import java.util.Scanner;

/**
 * Created by misanand on 4/14/15.
 */
public class TavasAndSaDDas {
    static int f(int num, int limit){
        if (num >= limit) return 0;
        return f(num *10 + 4, limit) + f(num *10 + 7,limit) +1;
    }
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String num = Integer.toString(n);
        int len = num.length();
        long count = 0;
        if (n == 4 ){
            System.out.println(1);
            return;
        }
        if (n == 7) {
            System.out.println(2);
            return;
        }
        for (int i=1;i<len;i++) count += Math.pow(2,i);
        int mul = 1;
        for (int i=0;i<len;i++) {
            if (num.charAt(i) == '7') mul *=2;
            if (num.charAt(i) == '4' && mul > 1) mul=2*mul -1;
        }
        System.out.println(count+mul);
        scanner.close();
    }
}

//package com.company;
import java.util.*;
public class Main {

    public static long Solver(long x,long N)
    {
        if(x > N) return 0;
        if(x == 444444444 || x == 777777777)
            return 1;
        long a,b;
        a=b=0;
        if(x*10 < 1000000000)
            a = Solver((x*10+4),N);
        if(x*10 < 1000000000)
            b = Solver((x*10+7),N);
        return 1 + a + b;
    }

    public static void main(String[] args) {
	    Scanner scan= new Scanner(System.in);

        ArrayList<Integer> luck = new ArrayList<Integer>();
        int N=scan.nextInt();
        System.out.println( Solver(4,N) + Solver(7,N));

	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class TavasAndSaddas {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String s = br.readLine();
        int L = s.length();
        int res = 1 << L;
        for(int i = 0; i < L; i++) {
            if(s.charAt(i) == '7') res |= (1 << (L-i-1));
        }

        bw.write(Integer.toString(res-1));
        bw.newLine();
        bw.flush();
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Ada {

    public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
//        int t=sc.nextInt();
//        sc.nextLine();
//        while (t-->0){
            String n=sc.nextLine();
            int length=n.length();
            int sum=0;
            for (int i=1;i<length;i++){
                sum+=(1<<i);
            }
            int lastSum=1;
            for (int i=0;i<length;i++){
                if (n.charAt(i)=='7'){
                    lastSum+=(1<<(length-i-1));
                }
            }
            System.out.println(sum+lastSum);

//        }
    }
}

import java.io.*;
import java.util.*;

public class Sequence{
   public static void main(String args[])throws IOException{

      int a = 0;
      int b = 0;
      int i;
      int k;
      ArrayList<String> list = new ArrayList<>();
      Boolean err;
      String str = "";
      char arr[];
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              //Делаем
      do{
         try{
            err = false;
       //     System.out.println("Введите число из последовательности (4,7,44,77,444....) : ");
            str = br.readLine();
         /*   arr = str.toCharArray();

            for(char current : arr){
               if(current == '4' || current == '7'){
                  continue;
               }else{
                  throw new NumberFormatException();
               }
            }
                */
         }catch (NumberFormatException e) {
            err = true;
            System.out.println("Неккоректное число");
         }
      } while( err == true);

      String array[][] = new String[10][];

      for(i = 0,k = 2; i < 10;i++,k = k*2){
         array[i] = new String[k];
      }

      array[0][0] = "4";
      array[0][1] = "7";

      while ( a < 9 ) {
         for(String s : array[a]){
            for(String j : array[0]){
               array[a+1][b] = s+j;
               b++;
            }
         }
         b = 0;
         a +=1;

      }

      for(String[] n : array){
         for(String j : n){
            list.add(j);
         }
      }

      a = list.indexOf(str)+1;
      System.out.print(a);
      br.close();

   }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by SvoyakMartin on 20.11.2015.
 */
public class t4
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s;
        int n = 0;
        for (int i = 0; i < 1;)
        {
            int err = 0;
     //       System.out.println("\nВведите число n из последовательности 4,7,44,47,74,77,444...");
            s = reader.readLine();
            if (!test("" + s)){
       //         System.out.println("Требуется ввод числа из указанной последовательности" +
        //                "\nn не должно превышать 10^9");
                err++;
            } else {
                n = Integer.parseInt(s);
            }
            if (err == 0){
                break;
            }
        }

        //составляем последовательность
ArrayList list = new ArrayList();
        for (int i = 0; i < 9; i++)
        {
            if (i == 0) {
                list.add("4");
                list.add("7");
            } else {
                int st;
                if (i == 1) {
                    st = ((int) Math.pow(2, i)-2);
                } else {
                    st = ((int) Math.pow(2, i));
                }
                for (int j = st; j < Math.pow(2, i+1) ; j++)
                {
                    list.add(list.get(j) + "4");
                    list.add(list.get(j) + "7");
                }
            }
        }

        int[] seq = new int[list.size()-4]; //не ясно зачем, но ArrayList отказывается нормально сортироваться
        for (int i = 0; i < list.size()-4; i++)
        {
            if (list.get(i).toString().length() > 9) break;
            seq[i] = (Integer.parseInt("" + list.get(i)));
        }
        Arrays.sort(seq);
        //наконец сама проверка
        int count = 1;
        for (int i = 0; i < seq.length; i++)
        {
            if (seq[i] == n){
                break;
            } else {
                count++;
            }
        }

/*      //первый вариант, рабочий, но слишком ресурсоёмкий для такой задачи
        for (int i = 0; i < 777777778; i++) // при больших значениях вешаем машину на несколько минут перебором и жрём ~500МБ памяти, не канает
        {
            if (test("" + i)){
                count++;
            }
            if (i == n){
                break;
            }
        }*/
      //  System.out.println("Число " + n + " занимает позицию №" + count + " в исходной последовательности");
        System.out.println(count);
    }

    public static boolean test(String testString){
        Pattern p = Pattern.compile("^[4,7]{1,9}$");
        Matcher m = p.matcher(testString);
        return m.matches();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            List<Long> L = new ArrayList<>();

            for (int i = 1; i <= 10; i++)
            {
                char[] num = new char[i];
                for (int j = 0; j <= (1 << i) - 1; j++)
                {
                    Arrays.fill(num, '4');
                    for (int bitPos = 1; bitPos <= 10; bitPos++)
                    {
                        int bit = CPUtils.getIthBitFromInt(j, bitPos);
                        if (bit >= 1)
                        {
                            num[bitPos - 1] = '7';
                        }
                    }
                    L.add(Long.valueOf(new StringBuilder(new String(num)).reverse().toString()));
                }
            }
            out.println(L.indexOf((long) N) + 1);
        }

    }

    static class CPUtils
    {
        public static int getIthBitFromInt(int bits, int i)
        {
            return (bits >> (i - 1)) & 1;
        }

    }
}

//package Tavas_and_SaDDas;

import java.util.Scanner;

/**
 * Created by kanghuang on 5/31/15.
 */
public class B {
    public static void main(String[] arg){
        Scanner reader = new Scanner(System.in);
        String luckyNum = reader.next();
        int sum = 0;
        int mul = 1;
        int num = 0;
        for (int i = 0; i < luckyNum.length(); i++){
            mul = mul * 2;
            sum += mul;
            mul = sum;
            if (luckyNum.charAt(i) == '7') {
                num = num * 2 + 1;
            }
            else{
                num = num * 2;
            }
        }
        //System.out.println(sum);
        System.out.print(sum + (int)Math.pow(2,luckyNum.length())-1-num);
    }
}

import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        String n = ir.next();
        int len = n.length(), total = 0;

        for (int i = len - 1; i >= 1; i--) total += Math.pow(2, i);
        for (int i = 1; i <= len; i++) {
            if (n.charAt(i - 1) == '7') total += Math.pow(2, len - i);
            else if (i == len && n.charAt(i - 1) == '4') total += 1;
            else if (i == len && n.charAt(i - 1) == '7') total += 2;
        }

        pw.print(total);

    }

}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}

import java.util.*;
public class TavasandSaDDas
{
	public static void main (String[]args)
	{
		Scanner i=new Scanner(System.in);
		String s=i.next();
		int w=0;
		for(int q=s.length();q>0;)
			w+=Math.pow(2,--q)*((s.charAt(q)-'0'+1)/4);
		System.out.println(w);
	}
}

import java.util.Scanner;

public class TavasAndSaDDas {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag = true;
		int ans = 0;
		int len = 0;
		while(n > 0){
			if(n%10 == 7){
				ans += 1 << len;
			}
			len++;
			n /= 10;
		}

		for (int i = 1; i < len; i++) {
			ans += i<< i;
		}
		System.out.println(ans+1);
	}
}

import java.util.*;
import java.io.*;

 public class Param
{

      public static  void main( String[]args)
    {
    Scanner param = new Scanner(System.in);
   int n=param.nextInt();
   int r=0;
   int count=0;
   ArrayList<Integer>l1=new ArrayList<Integer>();
  while(n!=0){
     r=n%10;
     l1.add(r);
     count++;
     n=n/10;
  }
  int sum=0;

  sum=(int)Math.pow(2,(count-1));

  for(int i=0;i<count;i++){
     if(l1.get(i)>4){
        sum=sum+2;
     }
     else{
        sum+=1;
     }
  }

  System.out.println(sum);
}
}

import java.util.*;
public class sol
{
    public static void main(String ar[])
    {
        Scanner scan=new Scanner(System.in);
        String n=scan.next();
        StringBuffer sb= new StringBuffer();
        for(int i=0;i<n.length();i++)
        {
            if(n.charAt(i)=='4')
                sb.append('0');
            else
                sb.append('1');
        }
        System.out.println(n.length()+1+Integer.parseInt(sb.toString(),2));
    }
}

import java.io.*;

public class tava {

    static Reader in;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        in = new Reader(inputStream);
        out = new PrintWriter(outputStream);
        String no = in.readLine();
        solve(no);
        out.close();
    }

    private static void solve(String n) {
        int len = n.length();
        long dis = 0;
        for (int i = 0; i < len; i++) {
            if (n.charAt(i) == '4') {
                dis = 2*dis + 1;
            }
            else {
                dis = 2*dis + 2;
            }
        }
        out.println(dis);
    }

    private static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(InputStream inputStream)
        {
            din = new DataInputStream(inputStream);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[BUFFER_SIZE]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c;
            c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c;
            c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}

import java.util.Scanner;

public class af {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int[] ar = new int[a.length()];
        for(int i = 0; i < ar.length; i++){
            ar[i]= a.charAt(i) - '0';
        }
        int sum=0;

        for(int i = 0; i < ar.length; i++){
            if(ar[i] >= 7){

                if(i == ar.length-1){
                    sum+=2;
                }else{
                    sum+=Math.pow(2, a.length() - i)/2;

                }
            }else if(ar[i] < 4){
                break;
            }else{
                if(i == ar.length){
                    sum++;
                }
            }
        }
        for(int i = 1; i < a.length(); i++){
            sum+=Math.pow(2, i);
        }
        System.out.println(sum);
    }

}

import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws IOException {
        // PrintStream out = new PrintStream(new
        // FileOutputStream("out.out"));
        Scan scan = new Scan();
        Queue<String> q = new LinkedList<String>();
        int n = scan.nextInt();
        int a[] = new int[510];
        q.add("4");
        q.add("7");
        int top = 0;
        while(!q.isEmpty()){
            String s = q.poll();
            a[top++] = Integer.parseInt(s);
            if(s.length()>=8)
                continue;
            else{
                q.add(s+"4");
                q.add(s+"7");
            }
        }
        Arrays.sort(a);
        for(int i = 0;i<510;i++){
            if(a[i]==n){
                out.println(i+1);
                break;
            }
        }
        out.flush();
    }
}

class Scan {

    BufferedReader buffer;
    StringTokenizer tok;

    Scan() {
        buffer = new BufferedReader(new InputStreamReader(System.in));
        // FileReader filereader=null;
        // try {
        // filereader = new FileReader("in.in");
        // } catch (FileNotFoundException e) {
        // // TODO Auto-generated catch block
        // e.printStackTrace();
        // }
        // buffer = new BufferedReader(filereader);
    }

    boolean hasNext() {
        while (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(buffer.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    String next() {
        if (hasNext())
            return tok.nextToken();
        return null;
    }

    String nextLine() {
        String s = null;
        try {
            s = buffer.readLine();
        } catch (Exception e) {
            return null;
        }
        return s;
    }

    char nextChar() {
        try {
            return ((char) buffer.read());
        } catch (Exception e) {
        }
        return '\0';
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class nbit {
	public static void main(String[] args) {
//		for(int j1=1;j1<=9;j1++)
//			for(int i=1;i<(int)Math.pow(2,j1);i++)
//			{
//				String val="";
//				long j=i;
//				while(j>0)
//				{
//					long x=j%2;
//					val+=x;
//					j=j/2;
//					//System.out.println(j);
//				}
//				//System.out.println(val);
//				StringBuilder ans=new StringBuilder(val);
//				System.out.println(ans.reverse());
//				l.add(Long.parseLong(new String(ans.reverse())));
//			}
		List<Long> list = new ArrayList<Long>();
		long x=0;
		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j < (int) Math.pow(2, i); j++) {
				String val = "";
				long copy =x;
				for (int k = 0; k < i; k++) {
					long p = copy%2;
					if(p == 0) {
						val  = val+Long.toString(4);
					}else {
						val  = val+Long.toString(7);
					}
					// System.out.println(val);
					copy = copy/2;
				}
			     x++;
				StringBuilder ans = new StringBuilder(val);
				System.out.println(ans.reverse());
				list.add(Long.parseLong((new String(ans.reverse()))));
			}
		}
		Collections.sort(list);
		System.out.println(list);
		Scanner sc = new Scanner(System.in);
	    long q = sc.nextLong();
	    System.out.println(list.indexOf(q)+1);
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
    public static void main(String[] argv) {
        MainRun mainSolve = new MainRun();
        mainSolve.run(0, 0);
    }
}

class Task {
	TreeSet <Long> st;
	long getNum(int mass[]) {
		long res = 0;
		for (int i = 1; i < 12; i++) {
			if (mass[i] == 0)
				break;
			res = res * 10L + mass[i];
		}
		return res;
	}
	void rec(int pos, int mass[]) {
		if (pos > 11) {
			st.add(getNum(mass));
			return;
		}
		mass[pos] = 0;
		rec(pos + 1, mass);
		mass[pos] = 4;
		rec(pos + 1, mass);
		mass[pos] = 0;
		mass[pos] = 7;
		rec(pos + 1, mass);
		mass[pos] = 0;
	}
	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int len = 0;
		int temp = n;
		while (temp != 0) {
			len++;
			temp /= 10;
		}
		int dl[] = new int[14];
		st = new TreeSet<Long>();
		rec(1, dl);

		int num = 1;
		Iterator it = st.iterator();
		while (it.hasNext()) {
			long value = (long)it.next();
			if (value == n) {
				out.println(num);
				return;
			}
			num++;
		}
	}
}

class MainRun {
	void run(int inF, int outF) {
//		inF = outF = 0;
		String input = "input.txt";
//		String input = "large.in";
		String output = "output.txt";
//		String output = "puzzle-2048.out";
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in;
		PrintWriter out;
		if (inF == 1)
			in = new InputReader(input);
		else
			in = new InputReader(inputStream);
		if (outF == 1)
			out = getPrintWriter(output);
		else
			out = getPrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}
	public static PrintWriter getPrintWriter(OutputStream stream) {
		return new PrintWriter(stream);
	}
	public static PrintWriter getPrintWriter(String f) {
		try {
			return new PrintWriter(new File(f));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
}

class InputReader {
	BufferedReader reader;
	StringTokenizer tokenizer;
	InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}
	InputReader(String f) {
		try {
			reader = new BufferedReader(new FileReader(f));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		tokenizer = null;
	}
	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch(IOException e) {
				throw new RuntimeException(e);
			} catch(NullPointerException e) {
				return "";
			}
		}
		return tokenizer.nextToken();
	}
	public String getLine() {
		try {
			return (String)reader.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public char nextChar() {
		return next().charAt(0);
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	public int[] nextIntArray(int n) {
		int a[] = new int[n + 2];
		for (int i = 1; i <= n; i++)
			a[i] = nextInt();
		return a;
	}
}

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        String s = Integer.toString(x);
        int n = s.length();
        int res = (int) (2 * (Math.pow(2, n-1) - 1));
        while(x > 0) {
            int r = x % 10;
            if(r == 7)
                res += 2;
            else
                res += 1;
            x /= 10;
        }
        System.out.println(res);
    }
}

import java.util.Scanner;

//in the name of god
public class B {

	public static void main(String[] args){

		Scanner s=new Scanner(System.in);

		long no=s.nextLong();
		int i=1;
		while(true){
		if(no-(1<<i)>=0)
		{
			no-=(1<<i);

			++i;}
		else break;
		}

		if(no==0){
		i-=1;
			while(i-->0){
				System.out.print(7);
			}
			return;
		}
		no-=1;
		int ans=(int)no;

		String ans1=Integer.toBinaryString(ans);
		int remain=i-ans1.length();
		while(remain-->0){

			System.out.print(4);
		}

		for(int j=0;j<ans1.length();j++){
			if(ans1.charAt(j)=='0'){
				System.out.print(4);
			}else{
				System.out.print(7);
			}
		}

	}

}

import java.util.*;
import java.io.*;
import java.math.*;
public class Euler {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		String str = in.next();
		int n = str.length();
		int ans =  ((int)Math.pow(2, str.length()) ) - 2;
		boolean bol = true;

		for (int i = 0; i < str.length(); i++) {

			if (str.charAt(i) == '4') {
				continue;
			}
			if (str.charAt(i) == '7') {
				ans += ((int)Math.pow(2, n - 1 - i));
			}

		}

		for (int i = 0; i < n; i++) {
			if (str.charAt(i) != '4') {
				bol = false;
			}
		}

		if (str.charAt(n - 1) == '7') ans++;

		ans += bol ? 1 : 0;

		System.out.println(ans);

	}
}

import java.util.Scanner;

public class Test6 {

    /**
     * @param args
     */
    public static int count(int n){
        int w =(n+"").length();
        int sum = 0;
        int count = 1;
        for(int i=1;i<w;i++){
            sum+=Math.pow(2,i);
        }
        for(int j=0;j<w;j++){
        String s = String.valueOf((String.valueOf(n)).charAt(j));

        if(s.equals("4")){
            count = count*1;
        }
        if(s.equals("7")){
            count = count*2;
        }
        }
        return sum+count;
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(count(n));
    }

}

import java.util.Scanner;

public class TestP1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long Num = scan.nextLong();
        System.out.println(getLuckyNumberCount(Num));
    }
    public static int getLuckyNumberCount(long inputNumber) {

        int luckyNumberCount = 0;
        if (inputNumber > (long)1000000000 || inputNumber < 4) {
            return 0;
        }
        long clone;
        int value;
        int digit = getDigit(inputNumber);
        long min;
        long max;
        for (int j = 0; j < digit; j++) {

            for (int i = 4; i <= 7;) {
                min = getMin(j, i);
                max = getMax(j, i);
                long pitch = 0;
                int pitchIndex = 1;

                for (long k = min; k <= max;) {
                    clone = k ;
                    if (clone > inputNumber)
                        break;
                    do {
                        value = (int) (clone % 10);
                        if (value != 4 && value != 7) {
                            break;
                        }
                        else {
                            clone = clone / 10;
                            if (clone == 0 || clone == 4 || clone == 7) {
                                System.out.println("bgjun :: k " + k);
                                luckyNumberCount++;
                                break;
                            }
                        }
                    }while(true);
                    k = k - pitch;
                    pitch = getPitchValue(pitchIndex);
                    pitchIndex++;
                    k = k + pitch;
                }

                if (i == 4) {
                    i = 7;
                } else {
                    break;
                }
            }
        }
        return luckyNumberCount;
    }

    public static int getDigit(long input) {
        int count = 1;
        long value = input;
        do {
            value = value / 10;
            if (value == 0) break;
            count++;
        }while(true);
        return count;
    }

    public static long getPitchValue(int pitchIndex) {
        long v = 0;
        int i = pitchIndex;
        int count = 0;
        do {
            int moc = i / 2;
            int re = i % 2;
            if (re != 0) {
                v = v + (long) (3 * Math.pow(10, count));
            }
            if (moc == 0) {
                break;
            } else {
                i = moc;
            }
            count++;
        }while(true);
        return v;
    }

    public static long getMin(int j, int i) {
        long v = 0;
        if (j == 0) {
            return i;
        }

        for (int x = 0; x <= j - 1; x++) {
            v += Math.pow(10, x) * 4;
        }
        v += Math.pow(10, j ) * i;
        return v;
    }

    public static long getMax(int j, int i) {
        long v = 0;
        if (j == 0) {
            return i;
        }

        for (int x = 0; x <= j - 1; x++) {
            v += Math.pow(10, x) * 7;
        }
        v += Math.pow(10, j ) * i;
        return v;
    }
}

import java.util.Scanner;

public class TavasAndSaDDas {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag = true;
		int ans = 0;
		int len = 0;
		while(n > 0){
			if(n%10 == 7){
				ans |= 1 << len;
			}
			len++;
			n /= 10;
		}

		for (int i = 1; i < len; i++) {
			ans += i<< i;
		}
		System.out.println(ans+1);
	}
}

import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    int sum[] = new int[9];
    int calc(String num) {
        char c = num.charAt(0);
        int m;
        if(c == '4')
            m = 1;
        else
            m = 2;
        if(num.length() == 1) {
            return m;
        } else {
            return m*sum[num.length() - 2] + calc(num.substring(1));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.readLine();
        sum[0] = 2;
        for (int i = 0; i < 8; i++) {
            sum[i+1] = sum[i]*3;
        }
        out.println(calc(s));
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

}

import java.util.Scanner;

public class Codeforces535B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int cur = in.nextInt();
        int poisk = cur;
        int rasr = 0;
        int kol = 0;
        int now = 0;
        int plus = 1;
        while (poisk != 0) {
            rasr++;
            kol += rasr * 2;
            now += plus * 4;
            plus *= 10;
            poisk /= 10;
        }
        kol -= rasr * 2;
        StringBuilder s = new StringBuilder(Integer.toString(now));
        StringBuilder need = new StringBuilder(Integer.toString(cur));
        if (need.length() == 1) {
            if (need.charAt(0) == '4') {
                System.out.println(1);
            } else {
                System.out.println(2);
            }
        } else {
            for (int j = 0; j < s.length() - 1; j++) {
                if (s.charAt(j) == need.charAt(j)) {
                    continue;
                } else {
                    kol += Math.pow(2, s.length() - j - 1) + 1;
                }
                if (kol == rasr * 2) {
                    break;
                }
            }
            if (kol == rasr * 2) {
                System.out.println(kol);
            } else {
                if (s.charAt(s.length() - 1) == need.charAt(s.length() - 1)) {
                    System.out.println(kol);
                } else {
                    System.out.println(kol + 1);
                }
            }
        }
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author llama
 */
public class Task2 {

    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int number = scanner.nextInt();
        int number = 0;
        System.out.println(position(number));
    }

    static int position(int number){
        int buf = number;
        int accelerator=0;
        int pow = 0;
        while (buf>0){
            int binary =0;
            if (buf%10==7) binary=1;
            buf/=10;
            accelerator+=binary<<pow++;
        }
        return accelerator+1;
    }
}

import java.util.Scanner;

public class TavasAndSaDDas {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n==4)
			System.out.println("1");
		else if(n==7)
			System.out.println("2");
		else{
			int ans = 1;
			int c = 0;
			while(n>10){
				ans = ans*2;
				if(n%10 == 4)
					c++;
				n = n/10;
			}
			if(n==4){
				ans = ans*2;
			}
			else
				ans = ans*3;
			if(c>0)
				ans--;
			System.out.println(ans);

		}

	}

}

import java.util.*;
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int ln = Integer.parseInt(br.readLine());

    int cnt = 1;
    int cnt_d = 1;
    int tmp = ln;
    int acc = 0;
    while (tmp / 10 != 0) {
      cnt *= 2;
      acc += cnt;
      cnt_d++;
      tmp /= 10;
    }

    int mask = (int) Math.pow(10, cnt_d - 1);
    int cnt2 = 0;
    while (cnt_d > 0) {
      int d = ln / mask;
      if (d == 7) {
        int inc = (cnt_d == 1)? 1: 2;
        cnt2 += inc;
      }
      cnt_d--;
      ln -= d * mask;
      mask /= 10;
    }

    acc += cnt2;
    System.out.println(acc + 1);
  }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class B {

	public static final String FOLDER_ROOT = "C:/ft/10/";

	public static void main(String[] args) throws Exception {
//		BufferedReader reader = new BufferedReader(new FileReader(FOLDER_ROOT + "B-sample.in"));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		long ans = Long.parseLong(str.replaceAll("4", "0").replaceAll("7", "1"), 2) + 1;
		int length = str.length();
		ans += Math.pow(2, length) - 1;
		System.out.println(ans);
	}
}

import java.util.Scanner;

public class Lucky {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter=0;
        int turn=1;
        while(n>0){
            if(n%10==4){
                counter+=1*turn;
            }
            else{
                counter+=2*turn;
            }
            turn++;
            n = n/10;
        }
        System.out.println(counter);
    }

}

import java.util.*;
public class geeks
{
    public static void main(String[] args) {
        Scanner obj=new Scanner(System.in);
        long n=obj.nextLong();
        long cpy=n;
        long count=0;
        while(cpy!=0) {
            count++;
            cpy = cpy / 10;
        }
        long res= (1<<count)-2;
        for(int i=0;i<n;i++)
        {
            if(n%10==7) res=res+(1<<i);
            n=n/10;
        }
        System.out.println((res+1));
    }
}

import java.util.Scanner;
public class Main {
    public static void main(String[]args){
        Scanner sc= new Scanner(System.in);

        String lucky = sc.nextLine();
        int length = lucky.length();
        int position=0;
        int counter=0;
        for(int i=length;i>0;i--){
            if(lucky.charAt(counter)=='7'){
            position+= Math.pow(2,i-1);
            }
            counter++;
        }
        position++;
        System.out.println(position);
        int sum=0;
        for(int i=length-1;i>0;i--){
            sum+= Math.pow(2,i);
        }
        position+=sum;

    }

}

import java.util.Scanner;

/**
 * Created by misanand on 4/14/15.
 */
public class TavasAndSaDDas {
    static int f(int num, int limit){
        if (num >= limit) return 0;
        return f(num *10 + 4, limit) + f(num *10 + 7,limit) +1;
    }
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String num = Integer.toString(n);
        int len = num.length();
        int count = 0;
        if (n == 4 ){
            System.out.println(1);
            return;
        }
        if (n == 7) {
            System.out.println(2);
            return;
        }
        count = (int) Math.pow(2,len-1);
        int _num = 0;
        int mul = 1;
        for (int i=0;i<len;i++) {
            if (num.charAt(i) == '7') mul *=2;
            if (num.charAt(i) == '4' && mul > 1) mul+=(mul -1);
        }
        //mul--;
        System.out.println(count+mul);
        scanner.close();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Ada {

    public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
//        int t=sc.nextInt();
//        sc.nextLine();
//        while (t-->0){
            String n=sc.nextLine();
            int length=n.length();
            int sum=0;
            for (int i=1;i<length;i++){
                sum+=(1<<i);
            }
            int lastSum=1;
            for (int i=0;i<length;i++){
                if (n.charAt(i)=='7'){
                    lastSum*=2;
                }
            }
            System.out.println(sum+lastSum);

//        }
    }
}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author debian-lover
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int score = input.nextInt();
        int counter = 0;
        String str = String.valueOf(score);
        for (int i = 0; i < str.length(); i++) {
            if(str.charAt(i)=='4'){
                counter += Math.pow(2, i);
            }else{
                counter += Math.pow(2, i+1);
            }
        }
        System.out.println(counter);
    }

}

import java.util.Scanner;

public class TestP1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long Num = scan.nextLong();
        System.out.println(getLuckyNumberCount(Num));
    }
    public static int getLuckyNumberCount(long inputNumber) {

        int luckyNumberCount = 0;
        if (inputNumber > (long)1000000000 || inputNumber < 4) {
            System.out.println("input error");
            return 0;
        }
        if (inputNumber > 777777777)
            inputNumber = 777777777;
        long clone;
        int value;
        int digit = getDigit(inputNumber);
        System.out.println("digit = " + digit);
        for (int j = 0; j < digit; j++) {
            for (int i = 4;i <= 7;) {
                for (long k = (long) (i * (Math.pow(10, j))) ; k < ((i+1) * (Math.pow(10, j))); k++ ) {
                    clone = k ;
                    if (clone > inputNumber)
                        break;
                    do {
                        value = (int) (clone % 10);
                        if (value != 4 && value != 7) {
                            break;
                        }
                        else {
                            clone = clone / 10;
                            if (clone == 0) {
                                luckyNumberCount++;
                                break;
                            }
                        }
                    }while(true);
                }

                if (i == 4) {
                    i = 7;
                } else {
                    break;
                }
            }
        }
        return luckyNumberCount;
    }

    public static int getDigit(long input) {
        int count = 1;
        long value = input;
        do {
            value = value / 10;
            if (value == 0) break;
            count++;
        }while(true);
        return count;
    }
}

import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.io.*;
import java.util.*;

public class Main {

public static class   ArrayHelper {

    public int [] sortAscendingArray(int [] intArray){

        int [] array = new int [intArray.length] ;
        System.arraycopy(intArray, 0, array, 0, array.length);
        boolean isSorted = false;
        int buf;
        while(!isSorted) {
            isSorted = true;
            for (int i = 0; i < array.length-1; i++) {
                if(array[i] > array[i+1]){
                    isSorted = false;

                    buf = array[i];
                    array[i] = array[i+1];
                    array[i+1] = buf;
                }
            }
        }
        return array;
    }

    //используется в 6 задаче, для получения сортированного массива номеров элементов сумм по стобцам и строкам
    /*public int [] sortAscendingArray2(int [] arrayAmount){
        int [] array = new int [arrayAmount.length] ;
        System.arraycopy(arrayAmount, 0, array, 0, array.length);
        boolean isSorted = false;
        int buf;
        int [] sortAmount = new int [array.length];
        for (int i=0; i<sortAmount.length; i++) {
            sortAmount[i] = i;
        }

        while(!isSorted) {
            isSorted = true;
            for (int i = 0; i < array.length-1; i++) {
                if(array[i] > array[i+1]){
                    isSorted = false;

                    buf = array[i];
                    array[i] = array[i+1];
                    array[i+1] = buf;

                    buf = sortAmount[i];
                    sortAmount[i] = sortAmount[i+1];
                    sortAmount[i+1] = buf;
                }
            }
        }
        return sortAmount;
    }*/

    public int [] stringToArrayInt (String string){
        char [] arrayChar = string.toCharArray();
        int [] array = new int[arrayChar.length];
        for (int i = 0; i < arrayChar.length; i++){
            array [i] = arrayChar[i] - '0';
        }
        return array;
    }
    //используется в 6 задаче, для получения чисел из строк, путём склейки цифр в число
    public int [] stringToArrayInt2 (String string, int length){

        char [] charArray = string.toCharArray();
        int [] intArray = new int[length];

        char space = ' '; //для проверки на пробел
        int ratio = 10;
        for (int i=0, j=0; i< charArray.length; i++){
            if (charArray[i] != space){
                intArray[j]*=ratio;
                intArray[j]+=charArray[i] - '0';
            } else {
                j++;
            }
        }
        return intArray;
    }

}

public static class ListHelper {

    public boolean checkItem ( ArrayList <Integer> list, int number){
        return list.contains((Integer)number);
    }
    public boolean checkMaxSumm (ArrayList <Integer> list, int number, int maxSumm){
        int summ=number;
        for (int element : list){
            summ+=element;
        }
        if (summ <=maxSumm) {
            return true;
        } else {
            return false;
        }
    }
    public boolean checkNotRepeat(ArrayList<ArrayList<Integer>> listTakenItems, List <Integer> listFirst, int number) {
        List<Integer> listChecked = new ArrayList<Integer>();
        listChecked.addAll(listFirst);
        listChecked.add(number);
        Collections.sort(listChecked);
        int count = 0;

        for (int i = 0; i < listTakenItems.size(); i++) {
            if (listTakenItems.get(i).size() == listChecked.size()) {
                for (int j = 0; j < listChecked.size(); j++) {
                    if (listTakenItems.get(i).get(j) == listChecked.get(j)) {
                        count++;
                    } else {
                        break;
                    }
                }
            }
            if (count==listChecked.size()){
                return false;
            } else {
                count = 0;
            }
        }
        return true;
    }

}

    public static void main(String[] args)throws IOException{

        //tests();

        Scanner scanner = new Scanner(System.in);

		int num = scanner.nextInt();
		printResult (num);
        scanner.close();
     /* BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String [] stringsThirdTask = new String[2];
		stringsThirdTask[0] = br.readLine();
        stringsThirdTask[1] = br.readLine();

        printResult(stringsThirdTask);
		*/
    }

    public static void printResult (int number ){
        ArrayHelper arrayHelper = new ArrayHelper();
        String string = String.valueOf(number);
        int [] arrayNumber = arrayHelper.stringToArrayInt(string);
        //сколько разрядов
        int base = arrayNumber.length;

        // разница между оконательной позицией и базовой
        int diff=0;

        for (int i=0; i<base;i++){
            if ((arrayNumber[i] - 4) > 0)
                diff += (int) Math.pow(2, i);
        }
        // позиция базового числа
        int basePosition = (int) Math.pow( 2,base)-1;
        int result = basePosition+diff;

        //System.out.println(Arrays.toString(difference));
        System.out.println(result);
    }
}

import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner  scn = new Scanner(System.in);

   		String n = scn.nextLine();

   		long ans =0;

   		ans += (1<<n.length())-2;

   		for(int i=0; i<n.length(); i++){
   			if(n.charAt(i) == '7'){
   				ans += (1<<i);
   			}
   		}

   		++ans;
   		System.out.println(ans);

    }
}

import java.util.Scanner;

public class TestP1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long Num = scan.nextLong();
        System.out.println("input value = " + Num);
        System.out.println(getLuckyNumberCount(Num));
    }

    public static int getLuckyNumberCount(long inputNumber) {

        int luckyNumberCount = 0;
        if (inputNumber > (long)1000000000 || inputNumber < 4) {
            System.out.println("input error");
            return 0;
        }
        long clone;

        for (long i = 4; i <= inputNumber; i++) {
            boolean breakValue = false;
            clone = i;
            int value;
            do {
                value = (int)(clone % 10);
                clone = clone / 10;
                if ( value != 4 && value != 7) {
                    breakValue = true;
                }
                else {
                    if (clone == 0) {
                        luckyNumberCount++;
                        breakValue = true;
                    }
                }
            }while (breakValue == false);
            breakValue = false;
        }
        return luckyNumberCount;
    }
}

 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        Scanner reader = new Scanner(System.in);
        String en = "1";
        long l = reader.nextLong();
        while (l > 0) {
            if (l % 10 == 7) {
                en += "1";
            } else {
                en += "0";
            }
            l /= 10;
        }
        System.out.println(Integer.parseInt(en, 2) - 1);
    }
}

import java.io.*;

import java.util.*;

public class Main {

    public static ArrayList<Integer>tree = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String word = s.next();
        int y = Integer.parseInt(word);

        algo(word.length(),0,"");

        int j=1;

        Collections.sort(tree);

        for(int i:tree){
            System.out.println(i);
            if(i==y){
                System.out.println(j);
                break;
            }
            j++;
        }

    }

    public static void algo(int n,int size,String word){

        if(size!=0)tree.add(Integer.parseInt(word));

        if(size==n){
            return;
        }

        algo(n,size+1,word+"4");
        algo(n,size+1,word+"7");

    }

}

class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(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();}

}

import java.util.*;

public class main {

	public static void main(String[] args) {
		 Scanner s = new Scanner(System.in);
        int n=s.nextInt();
        int c=0;
        int sum=0;
        int rem=0;
        int rev=0;
        while(n!=0) {
        	rem=n%10;
        	rev=(rev*10)+rem;
        	if(c>0)
        	sum+=(1<<c);
        	c++;
        	n=n/10;
        }
        while(rev!=0){
        	rem=rev%10;
        	if(rem==7)
        		break;
        	c--;
        	rev=rev/10;

        }
        sum+=(1<<c);
        System.out.print(sum);
	}
}

import java.io.*;
import java.util.*;
public final class tavas_and_sd
{
	static Scanner sc=new Scanner(System.in);
	static PrintWriter out=new PrintWriter(System.out);
	static long maxn=(long)Math.pow(10,9);

	public static void main(String args[]) throws Exception
	{
		char[] a=sc.next().toCharArray();
		int n=a.length;
		int c=0;
		for(int i=n-1;i>=0;i--)
		{
			for(int j=i;j>=0;j--)
			{
				if(a[j]=='7')
				{
					c+=2;
				}
				else
				{
					c++;
				}
			}
		}
		out.println(c);
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[]args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] num=input.readLine().split("");
        long index=0;
        for(int i=1;i<=num.length;i++){
            if(num[num.length-i].equals("4")){
                index+=Math.pow(2,i)-i;
            }
            else if(num[num.length-i].equals("7")){
                index+=Math.pow(2,i);
            }
        }
        System.out.println(index);

    }
}

//package Tavas_and_SaDDas;

import java.util.Scanner;

/**
 * Created by kanghuang on 5/31/15.
 */
public class B {
    public static void main(String[] arg){
        Scanner reader = new Scanner(System.in);
        String luckyNum = reader.next();
        int sum = 0;
        int mul = 1;
        int num = 0;
        for (int i = 0; i < luckyNum.length(); i++){
            mul = mul * 2;
            sum += mul;
            mul = sum;
            if (luckyNum.charAt(i) == '7') {
                num = num * 2 + 1;
            }
            else{
                num = num * 2;
            }
        }
        //System.out.println(sum);
        System.out.print(sum + (int)Math.pow(2,luckyNum.length())-1-num);
    }
}

import java.util.Scanner;

public class B535 {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);

        String number=sc.next(), binary="";
        int i,l=number.length(), decimal, result;
        for (i=0; i<l; i++)
        {
            if (number.charAt(i)=='4')
                binary+='0';
            else
                binary+='1';
        }

        decimal=Integer.parseInt(binary, 2);
        result=(int)Math.pow(2,l-1)*(l-1)+decimal+1;
        System.out.println(result);

    }
}

import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner  scn = new Scanner(System.in);

   		String n = scn.nextLine();

   		long ans =0;

   		int len = n.length();

   		ans = (1<<len)-2;

   		for(int i=0; i<len; i++){
   			if(n.charAt(i) == '7'){
   				ans += (1<<i);
   			}
   		}

   		++ans;
   		System.out.println(ans);

    }
}

import java.util.Scanner;

public class CF299B {
    public static void main(String[] args){
        Scanner keyboard = new Scanner(System.in);

        int n = keyboard.nextInt();
        int r = 0;
        String l = n + "";
        int ll = l.length();

        for (int i = 0; i < ll ; i++) {
            if((l.charAt(i) + "").equals("4"))
                r += 1*(ll-i);
            else
                r+= 2*(ll-i);
        }
        System.out.println(r);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashMap;
/**
 *
1.4
2.7

1.4
2.7
3.4+4
4+7
7+4
7+7
44+4
44+7
77+4
77+7

 *
 * */

public class B_Div2_299 {
    public static void main(String[]arg) throws IOException
    {
        HashMap<String, Long> map = new HashMap<String, Long>();
        ArrayDeque<String> q = new ArrayDeque<String>();

        char[]cs = {'4','7'};

        long index = 1;
        for(int i = 0;index < 3; index++,i++)
        {
            map.put(cs[i]+"", index);
            q.add(cs[i]+"");
        }

        boolean cont = true;
        String cad = "",nc;
        while(cont)
        {
            cad = q.poll();
            if(cad.equals("77777777"))
            {
                cont = false;
            }
            else
            {
                for(int i = 0; i < 2; i++)
                {
                    nc = cad+cs[i];
                    map.put(nc,index);
                    q.add(nc);
                    index++;
                }
            }
        }

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        long n = Integer.parseInt(in.readLine());
        System.out.println(map.get(n+""));
    }
}

import java.io.*;
import java.util.*;

public final class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = n + "";
        int len = s.length();
        String p = "";
        for (int i=0; i<s.length(); i++) {
            if (s.charAt(i) == '4') {
                p = '0' + p;
            }
            else {
                p = '1' + p;
            }
        }
        int x = Integer.parseInt(p, 2);
        int prev = (int)Math.pow(2,len-1);
        if (len == 1) {
            prev = 0;
        }
        int ans = x+1+prev;
        System.out.println(ans);
	}
}

import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int ans = 0;
        ans += (s.charAt(0)=='4' ? 1 : 0 );
        ans += (s.charAt(0)=='7' ? (1<<(s.length()-1))+1:0);
        int temp = 0;
        for(int i =1;i<s.length();i++){
            System.out.println((s.length() - i - 1));
            temp += 2 * (1 << (s.length() - i - 1) );
            if(s.charAt(i)=='7')
                temp += 1 << (s.length() - i - 1);
        }
        System.out.println(temp+ans);
     }
}

import java.io.*;
import java.util.*;

public class Ideone {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = n + "";
        int len = s.length();
        String p = "";
       for (int i=s.length()-1; i>=0; i--) {
            if (s.charAt(i) == '4') {
                p = '0' + p;
            }
            else {
                p = '1' + p;
            }
        }
       System.out.println(p);
        int x = Integer.parseInt(p,2);
        int prev = 0;
        for (int i=1; i<len; i++) {
            prev = prev + (int) Math.pow(2,i);
        }
        int ans = x+1+prev;
        System.out.println(ans);
	}
}

import java.util.Scanner;

public class B535 {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);

        String number=sc.next(), binary="";
        int i,l=number.length(), decimal, result;
        for (i=0; i<l; i++)
        {
            if (number.charAt(i)=='4')
                binary+='0';
            else
                binary+='1';
        }

        decimal=Integer.parseInt(binary, 2);
        System.out.println("l="+l);
        System.out.println(decimal);
        result=(int)Math.pow(2,l)+decimal-1;
        System.out.println(result);

    }
}

import java.io.*;
import java.util.*;

public final class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = n + "";
        String p = "";
        for (int i=0; i<s.length(); i++) {
            if (s.charAt(i) == '4') {
                p = '0' + p;
            }
            else {
                p = '1' + p;
            }
        }
        int x = Integer.parseInt(p, 2);
        System.out.println(x+1);
	}
}

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String luckyNumber = input.next();
        int digits = luckyNumber.length();
        int rank = 0;
        for (int i = 1; i <= digits - 1; i++) {
            rank += (1 << i);
        }
        rank += luckyRanker(luckyNumber);
        System.out.println(rank);
    }

    private static int luckyRanker(String luckyNumber) {
        if (luckyNumber.contentEquals("4")) {
            return 1;
        } else if (luckyNumber.contentEquals("7")) {
            return 2;
        } else {
            if (luckyNumber.charAt(0) == '7') {
                int rank = 1 << luckyNumber.substring(1).length();
                return rank + luckyRanker(luckyNumber.substring(1));
            }
        }
        return 0;
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            List<Integer> L = new ArrayList<>();

            for (int i = 1; i <= 8; i++)
            {
                char[] num = new char[i];
                for (int j = 0; j <= (1 << i) - 1; j++)
                {
                    Arrays.fill(num, '4');
                    for (int bitPos = 1; bitPos <= 8; bitPos++)
                    {
                        int bit = CPUtils.getIthBitFromInt(j, bitPos);
                        if (bit >= 1)
                        {
                            num[bitPos - 1] = '7';
                        }
                    }
                    L.add(Integer.valueOf(new StringBuilder(new String(num)).reverse().toString()));
                }
            }
            out.println(L.indexOf(N) + 1);
        }

    }

    static class CPUtils
    {
        public static int getIthBitFromInt(int bits, int i)
        {
            return (bits >> (i - 1)) & 1;
        }

    }
}

import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		FastReader file = new FastReader();
		String s = file.next();
		int cur = 0;
		int start = 1;
		int x = s.length();
		while (Math.pow(2, start) != Math.pow(2, x)) {
			cur += Math.pow(2, start);
			start++;
		}
		for (int i = x - 1; i >= 0; i--) {
			if (s.charAt(i) == '4') cur += 1;
			else cur += 2;
		}
		System.out.println(cur);
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.util.*;
import java.io.*;
import java.lang.*;

public class TavasAndSaddas{

    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer stk = new StringTokenizer("");
    public static void main(String args[]) throws Exception {
        int N = Integer.parseInt(bf.readLine());
        solver(N);
    }

    public static void solver(int N ){
        int digits = 0;
        int number_ = N;
        int totalLuckNo = 0;
        while( number_ > 0 ){
            digits++;
            number_ = number_ / 10 ;
        }

        for(int i=1 ; i< digits ;i++){
            totalLuckNo += calculatLuckNoOfDigits(i);
        }

        // for handling actual number of digits input number have
        totalLuckNo += calculateLuckNoForInput(digits , N );
        System.out.println(totalLuckNo );
    }

    public static int calculatLuckNoOfDigits(int digit){
        return 1 << digit ;
    }

    public static int calculateLuckNoForInput(int digit , int number ){
        int divisor = (int)Math.pow(10 , digit - 1 );
        int num_ = number;
        int tempcountstartwith7 = 0;
        int tempcountstartwith4 = 0;
        int index = 0;
        int numberstartswith = 0;
        while(num_ > 0){
            int firstdigit = num_ / divisor ;
            num_ = num_ % divisor;
            divisor /= 10;

            if(firstdigit == 7 ){
                if(index == 0){
                    numberstartswith = 7;
                    tempcountstartwith7 = 1;
                    tempcountstartwith4 = 1;
                }else{

                    tempcountstartwith7 *= 2;
                    tempcountstartwith4 *= 2;
                }
            }else{
                if(index == 0){
                    numberstartswith = 4;
                    tempcountstartwith4 = 1;
                }else{
                    if(numberstartswith == 7){
                        tempcountstartwith7 *= 1;
                        tempcountstartwith4 *= 2;
                    }else{
                        tempcountstartwith4 *= 1;
                        tempcountstartwith7 *= 1;
                    }

                }
            }
            index ++ ;
        }

        return tempcountstartwith7 + tempcountstartwith4 ;
    }

}

import java.util.Scanner;

public class af {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int[] ar = new int[a.length()];
        for(int i = 0; i < ar.length; i++){
            ar[i]= a.charAt(i) - '0';
        }
        int sum=0;

        for(int i = 0; i < ar.length; i++){
            if(ar[i] >= 7){

                if(i == ar.length-1){
                    sum+=2;
                }else{
                    sum+=Math.pow(2, a.length() - i)/2;

                }
            }else if(ar[i] < 4){
                break;
            }else{
                if(i == ar.length){
                    sum++;
                }
            }
        }
        for(int i = 1; i < a.length(); i++){
            sum+=Math.pow(2, i);
        }
        System.out.println(sum);
    }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author llama
 */
public class Task2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long number = scanner.nextLong();
        System.out.println(position(number));
    }

    static int position(long number){
        long buf = number;
        int accelerator=0;
        int pow = 0;
        while (buf>0){
            int binary =0;
            if (buf%10==7) binary=1;
            buf/=10;
            accelerator+=binary<<pow++;
        }
        return accelerator+1;
    }
}

import java.util.ArrayList;
import java.util.Scanner;

public class Lucky {

	public static int permutar(int n, ArrayList<Long>s, ArrayList<String>p){
		if (n==10) {
			return 0;
		}
		else{
		String[] x ={"4","7"};
		ArrayList<String> z = new ArrayList<String>();
		int s2 =p.size();
		for (int i=0;i<2;i++){
			for (int j=0;j<s2;j++){
				String g = x[i]+p.get((int)j);
				s.add(Long.parseLong(g));
				z.add(g);

			}
		}
		return permutar(n+=1,s,z);
	  }
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> x = new ArrayList<Long>();
		ArrayList<String> y = new ArrayList<String>();
		x.add((long) 4);
		x.add((long) 7);
		y.add("4");
		y.add("7");
		permutar(1,x,y);
		int sum=0;
		for (long j=0;j<x.size();j++){
			if (n>=x.get((int)j)){
				sum+=1;
			}else{
				break;
			}
		}
		System.out.println(sum);
		System.out.println(x);
	}

}

import java.util.*;
/**
 *
 * @author Archit
 */
public class tavasandSadda {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n1= n/10;
        int x = 1;
        int ans=0;
        while(n1!=0){
            x=x<<1;
            ans+=x;
            n1/=10;
        }
        n1=n;
        x = 0;
        while(n1!=0){
            x<<=1;
            if(n1%10==7) x+=1;
            n1/=10;
        }
        System.out.println(x+ans+1);

    }
}

import java.util.*;

public class Code {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int mas[] = new int[2000];
        mas[0] = 4;
        mas[1] = 7;
        int indexByAdd = 1;
        int index = 0;
        if (n == 4) {
            System.out.println(1);
            return;
        }
        if (n == 7) {
            System.out.println(2);
            return;
        }
        while (mas[indexByAdd] < n) {
            indexByAdd++;
            mas[indexByAdd] = mas[index] * 10 + 4;
            indexByAdd++;
            mas[indexByAdd] = mas[index] * 10 + 7;
            index++;
        }
        System.out.println(indexByAdd+1);
    }
}

import java.util.Scanner;

public class B535 {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);

        String number=sc.next(), binary="";
        int i,l=number.length(), decimal, result;
        for (i=0; i<l; i++)
        {
            if (number.charAt(i)=='4')
                binary+='0';
            else
                binary+='1';
        }

        decimal=Integer.parseInt(binary, 2);
        result=(int)Math.pow(2,l-1)*(l-1)+decimal+1;
        System.out.println(result);

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solution {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.valueOf(br.readLine());
        long s = 1;
        while (n > 0) {
            s = s << 1 | (n % 10) / 7;
            n = n / 10;
        }
        System.out.println(s - 1);
    }
}

import java.io.*;
import java.util.*;
public class LuckyNumbers {
    public static int[] convert(String s){
        StringBuilder str=new StringBuilder();
        StringBuilder str1=new StringBuilder();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='0')
            {str.append('4');str1.append('7');}
            else
            {str.append('7');str1.append('4');}
        }
        int v1 = Integer.parseInt(str.toString());
        int v2 = Integer.parseInt(str1.toString());
        int res[]=new int[2];
        res[0]=v1;
        res[1]=v2;
        Arrays.sort(res);
        return res;
    }
    public static void main(String args[])throws IOException{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int i=0;
        int c=0;
        HashSet<Integer> hs=new HashSet<>();
        for(i=0;;i++){
         String s=Integer.toBinaryString(i);
         int val[]=convert(s);
//         System.out.println(val[0]+" "+val[1]);
         if(val[0]>n && val[1]>n)
             break;
         if(val[0]<=n && hs.contains(val[0])==false){c++;hs.add(val[0]);}
         if(val[1]<=n && hs.contains(val[1])==false){c++;hs.add(val[1]);}
         if(val[0]==val[1])c--;
//         System.out.println(hs.toString());
        }
        System.out.println(c);
    }
}

import java.util.Scanner;

/**
 * Created by misanand on 4/14/15.
 */
public class TavasAndSaDDas {
    static int f(int num, int limit){
        if (num >= limit) return 0;
        return f(num *10 + 4, limit) + f(num *10 + 7,limit) +1;
    }
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String num = Integer.toString(n);
        int len = num.length();
        int count = 0;
        if (n == 4 ){
            System.out.println(1);
            return;
        }
        if (n == 7) {
            System.out.println(2);
            return;
        }
        count = (int) Math.pow(2,len-1);
        int _num = 0;
        int mul = 1;
        for (int i=0;i<len;i++) {
            if (num.charAt(i) == '7') mul *=2;
            if (num.charAt(i) == '4' && mul > 1) mul=2*mul -1;
        }
        //mul--;
        System.out.println(count+mul);
        scanner.close();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Ada {

    public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
//        int t=sc.nextInt();
//        sc.nextLine();
//        while (t-->0){
            String n=sc.nextLine();
            int length=n.length();
            int sum=0;
            for (int i=1;i<length;i++){
                sum+=(1<<i);
            }
            int lastSum=1;
            for (int i=0;i<length;i++){
                if (n.charAt(i)=='7'){
                    lastSum*=2;
                }
            }
            System.out.println(sum+lastSum);

//        }
    }
}

import java.util.*;

import static java.lang.Integer.max;
import static java.lang.Integer.reverse;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner( System.in );
        Integer m = sc.nextInt();
        int l=1;
        List<Integer> list = new ArrayList<>();
        Set<Integer> set = new HashSet<>();
        for ( int i=0; i<1025; i++ ) {
            StringBuilder st = new StringBuilder();
            for ( int j = 0; j < 9; j++ ) {
                if ( (i & (1<<j)) == 0 ) {
                    st.append( "4" );
                }
                else {
                    st.append( "7" );
                }

                Integer n = Integer.parseInt( st.reverse().toString() );
                if ( !set.contains( n ) ) {
                    set.add( n );
                    list.add( n );
                }
            }
        }
        Collections.sort( list );
        for ( int i = 0; i < list.size(); i++ ) {
            if ( list.get( i ) == m ) {
                System.out.println(i+1);
                return;
            }
        }
    }
}
/*
4
7
44
47
74
77
444
474
477
744
747
774
777*/

import java.util.Scanner;

/**
 * Created by misanand on 4/14/15.
 */
public class TavasAndSaDDas {
    static int f(int num, int limit){
        if (num >= limit) return 0;
        return f(num *10 + 4, limit) + f(num *10 + 7,limit) +1;
    }
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String num = Integer.toString(n);
        int len = num.length();
        int count = 0;
        if (n == 4 ){
            System.out.println(1);
            return;
        }
        if (n == 7) {
            System.out.println(2);
            return;
        }
        count = (int) Math.pow(2,len-1);
        int _num = 0;
        for (int i=0;i<len-1;i++) _num = _num*10 +4;
        count += f(_num,n);
        _num = 0;
        for (int i=0;i<len-1;i++) _num = _num*10 +7;
        count += f(_num,n) -1;
        System.out.println(count);
        scanner.close();
    }
}

/**
 * Created by Rukshar Alam on 10/18/2019.
 */
import java.util.*;
public class Tavas535B {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        int [] numbersInRange = new int[10];
        numbersInRange[0] = 0;numbersInRange[1] = 2;
        for(int i =2;i<10;i++)numbersInRange[i] = numbersInRange[i-1]*2;

        int [] partialSums = new int[10];

        partialSums[0] = 0;
        for(int i =1;i<10;i++)partialSums[i] = numbersInRange[i-1]*numbersInRange[i];

        String nStr = Integer.toString(n);
        int len = nStr.length();
        int position = partialSums[len-1];
        char bits[] = new char[len];
        for(int i =0;i<len;i++){
            if(nStr.charAt(i) =='4') bits[i] = '0';
            else bits[i] ='1';
        }

        String bitStr = new String(bits);

        int index = Integer.parseInt(bitStr, 2);
        position += (index+1);
        System.out.println(position);

    }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 String[] s=br.readLine().split("");
		 int[] n=new int[s.length];

		 for(int i=0;i<s.length;i++){
		 	n[i]=Integer.parseInt(s[i]);
		 }
		 Arrays.sort(n);
		 int p=0;
		 int m=s.length;
		 for(int i=m;i>0;i--){
		 	if(n[i-1]==7){
		 		p+=(int)Math.pow(2,i);
		 	}
		 	else{
		 		p+=(int)Math.pow(2,i-1);
		 	}
		 }
		 System.out.println(p);
	}
}

import java.util.Scanner;

public class tavassandsoddas {

	public static void main(String[] args) {
	Scanner s=new Scanner(System.in);
	String str=s.nextLine();
	int k=str.length()-1;
	int ans=0;
	if(k>0) {
		ans=ans+(1<<k);
	}
	String ptr="";
	for(int i=0;i<str.length();i++) {
		if(str.charAt(i)=='4') {
			ptr=ptr+0;
		}
		else {
			ptr=ptr+1;
		}
	}
	ans=ans+Integer.parseInt(ptr, 2)+1;
	System.out.println(ans);
}

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author llama
 */
public class Task2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        System.out.println(position(number));
    }

    static int position(int number){
        int buf = number;
        int accelerator=0;
        int pow = 0;
        while (buf>0){
            int binary =0;
            if (buf%10==7) binary=1;
            buf/=10;
            accelerator+=binary<<pow++;
        }
        return accelerator+1;
    }
}

import java.util.Scanner;

/**
 *
 * @author Tamil
 */
public class TavsAndSadds {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String val = s.next();
        StringBuilder res = new StringBuilder(val.length());
        if (res.length() % 2 == 0) {
            for (char c : val.toCharArray()) {
                if (c == '4') {
                    res.append('0');
                } else if (c == '7') {
                    res.append('1');
                }
            }
        }else{
            for (char c : val.toCharArray()) {
                if (c == '4') {
                    res.append('1');
                } else if (c == '7') {
                    res.append('0');
                }
            }
        }

        if (res.equals("4")) {
            System.out.println("1");
        } else if (res.equals("7")) {
            System.out.println("2");
        } else {
            int ans = 0;
            for (int i = res.length()-1; i >= 0; i--) {
                if (res.charAt(i) == '0') {
                    continue;
                } else {
                    ans += Math.pow(2, i);
                }
            }
            System.out.println(ans + 3);
        }
    }
}

import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int num=sc.nextInt();
		String s=Integer.toString(num);
		int l=s.length();
		long ans=(1<<l)-1;
		int p=1;
		for(int i=l-1;i>=0;i--) {
			if(s.charAt(i)=='4')
				continue;
			else {
				ans+=p;
			}
			p=p*2;
		}
		System.out.println(ans);

	}

}

import java.util.*;
  public class Solution{
     public static void main(String args[]){
     Scanner s=new Scanner(System.in);
     ArrayList<Integer> array=new ArrayList<Integer>();
     array.add(4);
     array.add(7);
     int size=array.size();
     int size1=0;
     int var=40;
     int var1=70;
     while(array.get(size-1)<1000000000){

          for(int i=size1;i<size;i++){
               int x=var+array.get(i);
               array.add(x);
          }
          for(int i=size1;i<size;i++){
               int x=var1+array.get(i);
               array.add(x);
          }
          size1=size;
          size=array.size();
          var=var*10;
          var1=var*10;
     }
          int input=s.nextInt();
          int count=1;
          for(int x=0;x<size;x++){
               if(array.get(x)==input){
                    break;
               }
               count++;

          }
          System.out.println(count);
     }

   }

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author llama
 */
public class Task2 {

    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int number = scanner.nextInt();
        int number = 0;
        System.out.println(position(number));
    }

    static int position(int number){
        int buf = number;
        int accelerator=0;
        int pow = 0;
        while (buf>0){
            int binary =0;
            if (buf%10==7) binary=1;
            buf/=10;
            accelerator+=binary<<pow++;
        }
        return accelerator+1;
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            List<Integer> L = new ArrayList<>();

            for (int i = 1; i <= 9; i++)
            {
                char[] num = new char[i];
                for (int j = 0; j <= (1 << i) - 1; j++)
                {
                    Arrays.fill(num, '4');
                    for (int bitPos = 1; bitPos <= 8; bitPos++)
                    {
                        int bit = CPUtils.getIthBitFromInt(j, bitPos);
                        if (bit >= 1)
                        {
                            num[bitPos - 1] = '7';
                        }
                    }
                    L.add(Integer.valueOf(new StringBuilder(new String(num)).reverse().toString()));
                }
            }
            out.println(L.indexOf(N) + 1);
        }

    }

    static class CPUtils
    {
        public static int getIthBitFromInt(int bits, int i)
        {
            return (bits >> (i - 1)) & 1;
        }

    }
}

import java.util.*;

public class Lucky {
	public static void main (String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int sum = 0;
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(str.length() - i -1) == '4')
				sum += 1;
			else
				sum += 2;
			// System.out.println(sum + " " + i);
			sum += 2 * (i == 0 ? 0 : 1);
			// System.out.println(sum + " " + i);
		}
		System.out.println(sum + "");
	}
}

/**
 * Created by Rukshar Alam on 10/18/2019.
 */
import java.util.*;
public class Tavas535B {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        int [] numbersInRange = new int[10];
        numbersInRange[0] = 0;numbersInRange[1] = 2;
        for(int i =2;i<10;i++)numbersInRange[i] = numbersInRange[i-1]*2;

        int [] partialSums = new int[10];

        partialSums[0] = 0;
        for(int i =1;i<10;i++)partialSums[i] = numbersInRange[i-1]*numbersInRange[i];

        String nStr = Integer.toString(n);
        int len = nStr.length();
        int position = numbersInRange[len-1];
        char bits[] = new char[len];
        for(int i =0;i<len;i++){
            if(nStr.charAt(i) =='4') bits[i] = '0';
            else bits[i] ='1';
        }

        String bitStr = new String(bits);

        int index = Integer.parseInt(bitStr, 2);
        position += (index+1);
        System.out.println(position);

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class B {

	public static final String FOLDER_ROOT = "C:/ft/10/";

	public static void main(String[] args) throws Exception {
//		BufferedReader reader = new BufferedReader(new FileReader(FOLDER_ROOT + "B-sample.in"));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		long ans = Long.parseLong(str.replaceAll("4", "0").replaceAll("7", "1"), 2) + 1;
		int length = str.length();
		ans += Math.pow(2, length) - 1;
		System.out.println(ans);
	}
}

//package Tavas_and_SaDDas;

import java.util.Scanner;

/**
 * Created by kanghuang on 5/31/15.
 */
public class B {
    public static void main(String[] arg){
        Scanner reader = new Scanner(System.in);
        String luckyNum = reader.next();
        int sum = 0;
        int mul = 1;
        int num = 0;
        for (int i = 0; i < luckyNum.length(); i++){
            mul = mul * 2;
            sum += mul;
            mul = sum;
            if (luckyNum.charAt(i) == '7') {
                num = num * 2 + 1;
            }
            else{
                num = num * 2;
            }
        }
        //System.out.println(sum);
        System.out.print(sum + (int)Math.pow(2,luckyNum.length())-1-num);
    }
}

import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws IOException {
        // PrintStream out = new PrintStream(new
        // FileOutputStream("out.out"));
        Scan scan = new Scan();
        Queue<String> q = new LinkedList<String>();
        int n = scan.nextInt();
        int a[] = new int[10000];
        q.add("4");
        q.add("7");
        int top = 0;
        while(!q.isEmpty()){
            String s = q.poll();
            a[top++] = Integer.parseInt(s);
            if(s.length()>=9)
                continue;
            else{
                q.add(s+"4");
                q.add(s+"7");
            }
        }
        Arrays.sort(a,0,top);
        for(int i = 0;i<510;i++){
            if(a[i]==n){
                out.println(i+1);
                break;
            }
        }
        out.flush();
    }
}

class Scan {

    BufferedReader buffer;
    StringTokenizer tok;

    Scan() {
        buffer = new BufferedReader(new InputStreamReader(System.in));
        // FileReader filereader=null;
        // try {
        // filereader = new FileReader("in.in");
        // } catch (FileNotFoundException e) {
        // // TODO Auto-generated catch block
        // e.printStackTrace();
        // }
        // buffer = new BufferedReader(filereader);
    }

    boolean hasNext() {
        while (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(buffer.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    String next() {
        if (hasNext())
            return tok.nextToken();
        return null;
    }

    String nextLine() {
        String s = null;
        try {
            s = buffer.readLine();
        } catch (Exception e) {
            return null;
        }
        return s;
    }

    char nextChar() {
        try {
            return ((char) buffer.read());
        } catch (Exception e) {
        }
        return '\0';
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.util.*;
public class sol
{
    public static void main(String ar[])
    {
        Scanner scan=new Scanner(System.in);
        String n=scan.next();
        StringBuffer sb= new StringBuffer();
        for(int i=0;i<n.length();i++)
        {
            if(n.charAt(i)=='4')
                sb.append('0');
            else
                sb.append('1');
        }
        if(n.length()==1)
        {
            if(n.charAt(0)=='4')
                System.out.println(1);
            else
                System.out.println(2);
        }
        else
            System.out.println(n.length()+1+Integer.parseInt(sb.toString(),2));
    }
}

import java.io.*;
import java.util.*;
public class LuckyNumbers {
    public static int convert(String s){
        StringBuilder str=new StringBuilder();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='0')
                str.append('4');
            else
                str.append('7');
        }
        return Integer.parseInt(str.toString());
    }
    public static void main(String args[])throws IOException{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int i=0;
        for(i=0;i<20;i++){
         String s=Integer.toBinaryString(i);
         int val=convert(s);
//         System.out.println(val);
         if(val==n)
             break;
        }
        System.out.println((i+1));
    }
}

import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws IOException {
        // PrintStream out = new PrintStream(new
        // FileOutputStream("out.out"));
        Scan scan = new Scan();
        Queue<String> q = new LinkedList<String>();
        int n = scan.nextInt();
        int a[] = new int[1000];
        q.add("4");
        q.add("7");
        int top = 0;
        while(!q.isEmpty()){
            String s = q.poll();
            a[top++] = Integer.parseInt(s);
            if(s.length()>=8)
                continue;
            else{
                q.add(s+"4");
                q.add(s+"7");
            }
        }
        Arrays.sort(a,0,top);
        for(int i = 0;i<510;i++){
            if(a[i]==n){
                out.println(i+1);
                break;
            }
        }
        out.flush();
    }
}

class Scan {

    BufferedReader buffer;
    StringTokenizer tok;

    Scan() {
        buffer = new BufferedReader(new InputStreamReader(System.in));
        // FileReader filereader=null;
        // try {
        // filereader = new FileReader("in.in");
        // } catch (FileNotFoundException e) {
        // // TODO Auto-generated catch block
        // e.printStackTrace();
        // }
        // buffer = new BufferedReader(filereader);
    }

    boolean hasNext() {
        while (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(buffer.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    String next() {
        if (hasNext())
            return tok.nextToken();
        return null;
    }

    String nextLine() {
        String s = null;
        try {
            s = buffer.readLine();
        } catch (Exception e) {
            return null;
        }
        return s;
    }

    char nextChar() {
        try {
            return ((char) buffer.read());
        } catch (Exception e) {
        }
        return '\0';
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.util.Scanner;

public class af {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int[] ar = new int[a.length()];
        for(int i = 0; i < ar.length; i++){
            ar[i]= a.charAt(i) - '0';
        }
        int sum=0;

        for(int i = 0; i < ar.length; i++){
            if(ar[i] >= 7){

                if(i == ar.length-1){
                    sum+=2;
                }else{
                    sum+=Math.pow(2, a.length() - i)/2;

                }
            }else if(ar[i] < 4){
                break;
            }else{
                if(i == ar.length){
                    sum++;
                }
            }
        }
        for(int i = 1; i < a.length(); i++){
            sum+=Math.pow(2, i);
        }
        System.out.println(sum);
    }

}

/**
 * Created by Rukshar Alam on 10/18/2019.
 */
import java.util.*;
public class Tavas535B {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        int [] numbersInRange = new int[10];
        numbersInRange[0] = 0;numbersInRange[1] = 2;
        for(int i =2;i<10;i++)numbersInRange[i] = numbersInRange[i-1]*2;

        int [] partialSums = new int[10];

        partialSums[0] = 0;
        for(int i =1;i<10;i++)partialSums[i] = numbersInRange[i-1]+numbersInRange[i];

        String nStr = Integer.toString(n);
        int len = nStr.length();
        int position = partialSums[len-1];
        char bits[] = new char[len];
        for(int i =0;i<len;i++){
            if(nStr.charAt(i) =='4') bits[i] = '0';
            else bits[i] ='1';
        }

        String bitStr = new String(bits);

        int index = Integer.parseInt(bitStr, 2);
        position += (index+1);
        System.out.println(position);

    }
}