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 A {
	static int mod = 1000000007;
	public static void main(String[] agrs) throws IOException {
	
//		PrintWriter pw = new PrintWriter(System.out);
		FastScanner sc = new FastScanner();
//		int yo = sc.nextInt();
//		while(yo-->0) {
//			
//		}
		String s = sc.next();
		
		boolean isBinary = true;
		for(char c : s.toCharArray()) {
			if(c != '0' && c != '1') {
				isBinary = false;
				break;
			}
		}
		
		if(isBinary) {
			System.out.println(binaryToDecimal(s));
			return;
		} 
		
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s.length(); i++) {
			sb.append('1');
		}
		
		if(Long.parseLong(sb.toString()) <= Long.parseLong(s)) {
			System.out.println(binaryToDecimal(sb.toString()));
		}
		else {
			for(int i = 0; i < s.length(); i++) {
				if(s.charAt(i) == '0') {
					sb.replace(i, i+1, "0");
					if(Long.parseLong(sb.toString()) <= Long.parseLong(s)) {
						System.out.println(binaryToDecimal(sb.toString()));
						return;
					}
				}
			}
		}
		
		
	}
	
	


	private static long binaryToDecimal(String s) {
//		System.out.println(s);
		long ans = 0;
		int power = 0;
		for(int i = s.length()-1; i >= 0; i--) {
			ans += (s.charAt(i)-'0') * Math.pow(2, power++);
		}
		return ans;
	}




	static class Pair{
		int x;
		int y;
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	static int gcd(int a, int b) {
		return a%b == 0 ? b : gcd(b,a%b);
	}
	
	
	
	static long pow(int a, int b) {
		if(b == 0) {
			return 1;
		}
		if(b == 1) {
			return a;
		}
		if(b%2 == 0) {
		
			long ans = pow(a,b/2);
			return ans*ans;
		}
		else {
			long ans = pow(a,(b-1)/2);
			return a * ans * ans;
		}
		
	}
	
	static boolean[] sieve(int n) {
		
		boolean isPrime[] = new boolean[n+1];
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) continue;
			for(int j = 2*i; j <= n; j+=i) {
				isPrime[j] = true;
			}
		
		}
		return isPrime;
		
	}


	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	
	
//	For Input.txt and Output.txt
	
//	FileInputStream in = new FileInputStream("input.txt");
//	FileOutputStream out = new FileOutputStream("output.txt");
//	PrintWriter pw = new PrintWriter(out);
//	Scanner sc = new Scanner(in);
 
}
