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.util.*;

public class hexadecimal
{
	public String nextSmallestRecons(int n)
	{
		String s = Integer.toString(n);
		int n_di = s.length();
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i< n_di; i++)
		{
			char p = s.charAt(i);
			int p1 = Character.getNumericValue(p);
			if (p1 > 1)
				{
					for (int j = i; j<n_di; j++)
						ans.append(1);
					break;
				}
			else
				ans.append(p1);
		}
		return(ans.toString().trim());
	}
	
	public static void main(String args[])throws IOException
	{
		Scanner sc = new Scanner(System.in);
		hexadecimal  hh = new hexadecimal();
		
		int n = sc.nextInt();
		String s = Integer.toString(n);
		int n_di = s.length();
		String ans = hh.nextSmallestRecons(n);
		int i = 1;
		int sum = 0;
		for (int j= 1; j<= n_di-1; j++)
		{
			sum += (int)Math.pow(2,j-1);
		}
		
		for ( i = 1; i< ans.length(); i++)
		{
			if (ans.charAt(i)=='1')
			{
				sum += (int)Math.pow(2, n_di-i-1);
			}
		}
		//0System.out.println(i+" here ");
		//sum += (int)Math.pow(2,n_di-i);
		//System.out.println(an1s);
		System.out.println(sum+1);
		
		
		
	}
	
	
}
