One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.

But his plan failed. The reason for this was very simple: Hexadecimal didn't perceive any information, apart from numbers written in binary format. This means that if a number in a decimal representation contained characters apart from 0 and 1, it was not stored in the memory. Now Megabyte wants to know, how many numbers were loaded successfully.

Input

Input data contains the only number n (1 ≤ n ≤ 109).

Output

Output the only number — answer to the problem.

Examples

Input

10


Output

2

Note

For n = 10 the answer includes numbers 1 and 10.
import java.io.*;
import java.math.*;
import java.util.*;
 
 
 
 
 
public class Subset {
 
    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static long H,W;
    static BitSet bs;
    static long mod = 1000000007;
    static int ans =0;
    static long bound =0;
    static HashSet<Long> set = new HashSet<>();
    static char [] arr = new char[11];
    
    public static void main(String args[]) throws IOException {
        long n =in.nextLong();
       // System.out.println(arr);
        subset(0);
        int cnt=0;
        for(long p:set){
            if(p<=n){
                cnt++;
            }
        }
        out.println(cnt-1);
        out.flush();
    }
    static void subset(int k){
        if(k==10){
            set.add(convertcharToStringToLong(k));
        }else if(k<10){
            arr[k] = '1';
            set.add(convertcharToStringToLong(k));
            subset( k+1);
            arr[k] = '0';
            set.add(convertcharToStringToLong(k));
            subset( k+1);
        }
    }
    
    private static long convertcharToStringToLong( int k)  {
        long  t  = 0;
        for(int i=0;i<k;i++){
         //   out.println(Math.pow(10, i)*(arr[i]-'0'));
                t+= Math.pow(10, i)*(arr[i]-'0');
        }
        return  t ;
    }

    private static long convertNumber(char[] arr) {
        String temp = "";
        for(int i=0;i<arr.length;i++){
          //  if(arr[i]!=null){
                temp+=arr[i];
            }
        
        return 8;
    }


    private static void findSubsets(int array[]) {
        int numOfSubsets = 1 << array.length;
    
        for (int i = 0; i < numOfSubsets; i++) {
            int pos = array.length - 1;
            int bitmask = i;
            String n = "";
         //   System.out.print("{");
            while (bitmask > 0) {
                if ((bitmask & 1) == 1){
                 //   System.out.print(array[pos] + ",");
                    n+=array[pos];
                }
                bitmask >>= 1;
                pos--;
            }
            if(n.length()>=1){
            long k = Long.parseLong(n);
            if(k<=bound&&!set.contains(k)){
                ans++;
                set.add(k);
            }
        }
            //out.println(n+" ");
          //  System.out.print("}");
        }
    }
    
    private static boolean hasZero(long k) {
        while(k!=0){
            long p = k%10;
            if(p==0){
                return true;
            }
            k/=10;
        }
        return false;
    }

    static boolean isVowel(char c) {
        if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y'){
            return true;
        }
        return false ;
    }
    static class IP implements Comparable<IP>{
        public int first,second;
        IP(int first, int second){
            this.first = first;
            this.second = second;
        }
        public int compareTo(IP ip){
            if(first==ip.first)
                return second-ip.second;
            return first-ip.first;    
        }
 
    }
        
       static long gcd(long a, long b){
        return b!=0?gcd(b, a%b):a;
    }
 
        static boolean isEven(long a) {
            return (a&1)==0;
        }
    
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           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;
        }
  
     }
}
