import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		} main {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long count = 1; count 1 boolean flag = true; flag true long ans = 0; ans 0 if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		} h == 1 h 1 {
			System.out.println("1");
		} System.out.println("1") System.out.println System.out System System.out "1" {
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		} if(!(h%2 == 0)){
				h = h-1;
			} !(h%2 == 0) (h%2 == 0) h%2 h 2 0 {
				h = h-1;
			} h = h-1 h h-1 h 1 while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			} flag {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			} if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				} h/2 == 1 h/2 h 2 1 {
					flag = false;
				} flag = false flag false {
					h = h/2;
					count++;
				} h = h/2 h h/2 h 2 count++ count long tmp = 1; tmp 1 for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			} int i = 0; int i = 0; i 0 i<count i count i++ i++ i {
				ans = tmp*2+1;
				tmp = ans;
			} {
				ans = tmp*2+1;
				tmp = ans;
			} ans = tmp*2+1 ans tmp*2+1 tmp*2 tmp 2 1 tmp = ans tmp ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long count = 1;
		boolean flag = true;
		long ans = 0;

		if(h == 1){
			System.out.println("1");
		}else{
			if(!(h%2 == 0)){
				h = h-1;
			}
			while (flag) {
				if(h/2 == 1){
					flag = false;
				}else{
					h = h/2;
					count++;
				}
			}
			long tmp = 1;
			for(int i = 0;i<count;i++){
				ans = tmp*2+1;
				tmp = ans;
			}
	System.out.println(ans);
		}
		}
}