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

public class Main {
	HashSet<Long> set = new HashSet<Long>();
	int n;
	private void solve() throws Exception {
		n = nextInt();
		int count = 0;
		for (int len = 1; len <= Integer.toString(n).length()+ 1; len++){
			for (int mask = 0; mask < 1<<len; mask++){
				String s = "";
				for (int j = 0; j < len; j++)
					if ((mask&(1<<j)) > 0) s += '1';
					else s += '0';
				long val = Long.parseLong(s);
				if (val <= n && val >= 1) {
					set.add(val);
				}
			}
		}
		out.println(set.size());
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;
	StreamTokenizer stn;

	private String next() throws Exception {
		if (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private int nextInt() throws Exception {
		if (ST)
			return (int) nextDouble();
		else
			return Integer.parseInt(next());
	}

	private long nextLong() throws Exception {
		if (ST)
			return (long) nextDouble();
		else
			return Long.parseLong(next());
	}

	private double nextDouble() throws Exception {
		if (ST) {
			stn.nextToken();
			return stn.nval;
		} else
			return Double.parseDouble(next());
	}

	private final boolean ST = false;

	public void run() throws Exception {
		if (ST)
			stn = new StreamTokenizer(new InputStreamReader(System.in));
		else
			in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		out.close();
	}

	public static void main(String... strings) throws Exception {
		new Main().run();
	}
}
