import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong(),count=0,sum=1;
		while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		}
		System.out.println(sum);
	}
}
 import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong(),count=0,sum=1;
		while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		}
		System.out.println(sum);
	}
} Main public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong(),count=0,sum=1;
		while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		}
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong(),count=0,sum=1;
		while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		}
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h=sc.nextLong() h sc.nextLong() sc.nextLong sc count=0 count 0 sum=1; sum 1 while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		} h!=1 h 1 {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		} count++ count h/=2 h 2 sum+=(long)Math.pow(2, count) sum (long)Math.pow(2, count) Math.pow Math 2 count System.out.println(sum) System.out.println System.out System System.out sum String[] $ $
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong(),count=0,sum=1;
		while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		}
		System.out.println(sum);
	}
}

