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.util.*;
import java.io.*;
import static java.lang.Math.*;

public class G {
          
          int n;
          int answer = 0;
          
          HashSet<Integer> h = new HashSet<Integer>();
          
          void r(int x){
                    if (x > n) return;
                    if (x <= n){
                            if (!h.contains(x))
                                      h.add(x);
                            r(x * 10);
                            r(x * 10 + 1);
                    }
          }
          
          void solve() throws IOException {
                    n = in.nextInt();
                    r(1);
                    out.println(h.size());
          }
          
          String input = "";
          String output = "";
          FastScanner in;
          PrintWriter out;
          
          void run() {
                    try {
                              BufferedReader bf;
                              if (input.length() == 0) {
                                        bf = new BufferedReader(new InputStreamReader(System.in));
                              } else {
                                        bf = new BufferedReader(new FileReader(input));
                              }
                              in = new FastScanner(bf);
                              
                              if (output.length() == 0) {
                                        out = new PrintWriter(System.out);
                              } else {
                                        out = new PrintWriter(new File(output));
                              }
                              
                              solve();
                              
                              out.close();
                    } catch (Exception ex) {
                              out.close();
                              ex.printStackTrace();
                    }
          }
          
          public static void main(String[] args) {
                    new G().run();
          }
          
          class FastScanner {
                    
                    BufferedReader bf;
                    StringTokenizer st;
                    
                    FastScanner(BufferedReader bf) {
                              this.bf = bf;
                    }
                    
                    String next() throws IOException {
                              while (st == null || !st.hasMoreTokens()) {
                                        st = new StringTokenizer(bf.readLine());
                              }
                              return st.nextToken();
                    }
                    
                    String nextLine() throws IOException {
                              String line = bf.readLine();
                              while (line.length() == 0) {
                                        line = bf.readLine();
                              }
                              return line;
                    }
                    
                    int nextInt() throws IOException {
                              return Integer.parseInt(next());
                    }
                    
                    long nextLong() throws IOException {
                              return Long.parseLong(next());
                    }
                    
                    double nextDouble() throws IOException {
                              return Double.parseDouble(next());
                    }
                    
                    int[] readIntArray(int n) throws IOException {
                              int[] a = new int[n];
                              for (int i = 0; i < n; i++) {
                                        a[i] = in.nextInt();
                              }
                              return a;
                    }
                    
                    long[] readLongArray(int n) throws IOException {
                              long[] a = new long[n];
                              for (int i = 0; i < n; i++) {
                                        a[i] = nextLong();
                              }
                              return a;
                    }
          }
}

				 	    	 					  			   	