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

		  		System.out.print(x);

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

		  		System.out.print(x);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long x=0;
		int count=0;
		while(h>0) {
			h/=2;
			count++;
		}
		for(int i=0;i<count;i++) {
			x+=Math.pow(2, i);
		}

		  		System.out.print(x);

	} main {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long x=0;
		int count=0;
		while(h>0) {
			h/=2;
			count++;
		}
		for(int i=0;i<count;i++) {
			x+=Math.pow(2, i);
		}

		  		System.out.print(x);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long x=0; x 0 int count=0; count 0 while(h>0) {
			h/=2;
			count++;
		} h>0 h 0 {
			h/=2;
			count++;
		} h/=2 h 2 count++ count for(int i=0;i<count;i++) {
			x+=Math.pow(2, i);
		} int i=0; int i=0; i 0 i<count i count i++ i++ i {
			x+=Math.pow(2, i);
		} {
			x+=Math.pow(2, i);
		} x+=Math.pow(2, i) x Math.pow(2, i) Math.pow Math 2 i System.out.print(x) System.out.print System.out System System.out x String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long x=0;
		int count=0;
		while(h>0) {
			h/=2;
			count++;
		}
		for(int i=0;i<count;i++) {
			x+=Math.pow(2, i);
		}

		  		System.out.print(x);

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long x=0;
		int count=0;
		while(h>0) {
			h/=2;
			count++;
		}
		for(int i=0;i<count;i++) {
			x+=Math.pow(2, i);
		}

		  		System.out.print(x);

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

		  		System.out.print(x);

	}
}