import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	}
} Main public static void main(String[] args) {
		System.out.println(solve());
	} main {
		System.out.println(solve());
	} System.out.println(solve()) System.out.println System.out System System.out solve() solve String[] args args public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	} solve {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N = sc.nextLong(); N sc.nextLong() sc.nextLong sc long sum = 0; sum 0 int i = 0; i 0 while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		} N != 0 N 0 {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		} sum += Math.pow(2, i) sum Math.pow(2, i) Math.pow Math 2 i N /= 2 N 2 i++ i return sum; sum public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	}
} public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	}
}
