import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	} main {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc int k = 0; k 0 while(h>0) {
			k++;
			h = h/2;
		} h>0 h 0 {
			k++;
			h = h/2;
		} k++ k h = h/2 h h/2 h 2 long time = 0 time 0 c = 1; c 1 for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		} int i=1; int i=1; i 1 i<=k i k i++ i++ i {
			time+=c;
			c*=2;
		} {
			time+=c;
			c*=2;
		} time+=c time c c*=2 c 2 System.out.println(time) System.out.println System.out System System.out time String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		long h = sc.nextLong();
		
		int k = 0;
		while(h>0) {
			k++;
			h = h/2;
		}
		
		long time = 0, c = 1;
		for(int i=1;i<=k;i++) {
			time+=c;
			c*=2;
		}
		
		System.out.println(time);
	}
}