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.
/*
 * Code Author: Mihir Shah
 * DA-IICT
 */
import java.io.*;
import java.math.*;
import java.util.*;

public class TestClass {

	InputReader in;
	PrintWriter out;
	TreeSet<Integer> all;
	
	TestClass() throws IOException {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
		// in = new InputReader(new FileInputStream("output_.txt"));
		// out = new PrintWriter(new File("output_.txt"));
		solve();
		out.close();
	}

	public static void main(String args[]) {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new TestClass();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	// --------------------My Code Starts Here----------------------
	int mod = (int) 1e9 + 7;

	public void solve() throws IOException {
		int n = in.nextInt();
		StringBuilder sb = new StringBuilder();
		sb.append("0000000000");
		all = new TreeSet<>();
		generateBinaryString(9, sb);
		all.remove(0);
		int count = 0;
		for(int i : all) {
			if(i <= n)
				count++;
		}
		out.println(count);
	}

	void generateBinaryString(int current, StringBuilder sb) {
		if(current < 0)
			return;
		sb.replace(current, current + 1, "0");
		// out.println(sb.toString());
		all.add(Integer.parseInt(sb.toString()));
		generateBinaryString(current - 1, sb);
		
		sb.replace(current, current + 1, "1");
		// out.println(sb.toString());
		all.add(Integer.parseInt(sb.toString()));
		generateBinaryString(current - 1, sb);
		
	}
	
	// ---------------------My Code Ends Here-----------------------
	static class Pair implements Comparable<Pair> {
		int x;
		int y;
		int i;
		long size;
		int pos;

		Pair(int xx, int yy) {
			x = xx;
			y = yy;
		}

		@Override
		public int compareTo(Pair o) {
			if (Long.compare(this.x, o.x) != 0)
				return -Long.compare(this.x, o.x);
			else
				return Long.compare(this.y, o.y);
		}
	}

	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public final int nextInt() throws IOException {
			return (int) nextLong();
		}

		public final long nextLong() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
				if (c == -1)
					throw new IOException();
			}
			boolean negative = false;
			if (c == '-') {
				negative = true;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return negative ? (-res) : (res);
		}

		public final int[] readIntBrray(int size) throws IOException {
			int[] arr = new int[size];
			for (int i = 0; i < size; i++)
				arr[i] = nextInt();
			return arr;
		}

		public final String next() throws IOException {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String nextLine() throws IOException {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (c != '\n' && c != -1);
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}
}