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.ArrayDeque;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		HexadecimalNumber solver = new HexadecimalNumber();
		solver.solve(1, in, out);
		out.close();
		System.exit(0);
	}
}
 
class HexadecimalNumber extends SimpleBasicSolution {
	static int[] binaries = new int[512];

	public void generate(int n) {
		// create an empty Queue and push 1 to it
		Queue<Integer> q = new ArrayDeque<>();
		q.add(1);

		// run n times
		for (int i = 1; i <= n; i++) {
			// append 0 and 1 to the front element of the queue and
			// enqueue both Strings
			q.add(q.peek()*10);
			q.add(q.peek()*10 +1);

			// pop the front element and print it
			binaries[i - 1] = q.poll();
		}
	}
  public void solve(int testNumber) {
	  int binaryLimit = 512;
	  generate(binaryLimit);
	  int count = 0;
	  int n = in.nextInt();
	  for (int binary : binaries) {
		  if (binary <= n) {
			  count++;
		  } else
			  break;
	  }
	  out.println(count);
  }
}
 
abstract class SimpleBasicSolution extends BasicSolution {
 
  public String processOutputPreCheck(int testNumber, String output) {
    return output;
  }
 
}
 
class InputReader {
 
	BufferedReader br;
	StringTokenizer in;
 
	public InputReader(InputStream inputStream) {
		br = new BufferedReader(new InputStreamReader(inputStream));
	}
 
	boolean hasMoreTokens() {
		while (in == null || !in.hasMoreTokens()) {
			String s = nextLine();
			if (s == null) {
				return false;
			}
			in = new StringTokenizer(s);
		}
		return true;
	}
 
	public String nextString() {
		return hasMoreTokens() ? in.nextToken() : null;
	}
 
	public String nextLine() {
		try {
			in = null;
			return br.readLine();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
 
	public int nextInt() {
		return Integer.parseInt(nextString());
	}
 
	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
 
}
 
abstract class BasicSolution {
 
  protected int testNumber;
 
  public InputReader in;
  public OutputWriter out;
 
  public abstract void solve(int testNumber);
 
  public abstract String processOutputPreCheck(int testNumber, String output);
 
	public void solve(int testNumber, InputReader in, OutputWriter out) {
    this.testNumber = testNumber;
 
    ByteArrayOutputStream substituteOutContents = new ByteArrayOutputStream();
    OutputWriter substituteOut = new OutputWriter(substituteOutContents);
 
    this.in = in;
    this.out = substituteOut;
 
    solve(testNumber);
    substituteOut.flush();
 
    String result = substituteOutContents.toString();
 
    result = processOutputPreCheck(testNumber, result);
    out.print(result);
    out.flush();
  }
 
}
 
class OutputWriter extends PrintWriter {
 
	public OutputWriter(OutputStream outputStream) {
		super(outputStream);
	}
 
}