// Arup Guha
// 10/12/2013
// Solution to UCF JV Practice Problem H: Hexadecimal's Numbers.

// Note: This is a non-intuitive solution. It iterates through the digits, counting up
//       all "binary" numbers we know to be less than our number based on looking at that
//       digit. Alternatively, we can simply convert our input to a binary number, going
//       left to right. 0s and 1s stay, when you reach the first digit greater than 1,
//       change all future digits to 1. Then, convert this number to binary.

import java.util.*;

public class h {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		char[] vals = stdin.next().toCharArray();
		int n = vals.length;

		// Store digits backwards.
		int[] digits = new int[n];
		for (int i=0; i<vals.length; i++)
			digits[n-1-i] = (int)(vals[i] - '0');

		int cnt = 0;
		for (int i=n-1; i>=0; i--) {

			// All combos from here on out work, add it and break.
			if (digits[i] > 1) {
				cnt += ((1 << (i+1)) - 1);
				break;
			}

			// If there's a 1 here, just add in all combos with a 0 in this slot.
			else if (digits[i] == 1) {
				cnt += (1 << i);
			}
		}

		// Here is our answer.
		System.out.println(cnt);
	}
}