import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		System.out.println(ans);
	 }
} import java.util.*; util.* java import java.util.ArrayDeque; ArrayDeque java.util import java.util.Queue; Queue java.util import java.math.RoundingMode; RoundingMode java.math import java.math.BigDecimal; BigDecimal java.math public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		System.out.println(ans);
	 }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		System.out.println(ans);
	 } main {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		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 ans = 1; ans 1 for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			} int i = 1; int i = 1; i 1 i < 41 i 41 i++ i++ i {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			} {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			} long right = 1; right 1 long left = 1; left 1 for(int j = 0; j < i-1; j++) {
					left*=2;
				} int j = 0; int j = 0; j 0 j < i-1 j i-1 i 1 j++ j++ j {
					left*=2;
				} {
					left*=2;
				} left*=2 left 2 for(int j = 0; j < i; j++) {
					right*=2;
				} int j = 0; int j = 0; j 0 j < i j i j++ j++ j {
					right*=2;
				} {
					right*=2;
				} right*=2 right 2 if(left<=H&&H<right) {
					ans = right-1;
					break;
				} left<=H&&H<right left<=H left H H<right H right {
					ans = right-1;
					break;
				} ans = right-1 ans right-1 right 1 break; 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 ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		System.out.println(ans);
	 }
} public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		System.out.println(ans);
	 }
} Main
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 1;
			for(int i = 1; i < 41; i++) {
				long right = 1;
				long left = 1;
				for(int j = 0; j < i-1; j++) {
					left*=2;
				}
				for(int j = 0; j < i; j++) {
					right*=2;
				}
				if(left<=H&&H<right) {
					ans = right-1;
					break;
				}
			}
		System.out.println(ans);
	 }
}