import java.util.*;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	}
} import java.util.*; util.* java public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	}
} Main static Main instance = new Main(); instance new Main() public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	} main {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              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 if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        } h == 1 h 1 {
          System.out.println(1);
          return;
        } System.out.println(1) System.out.println System.out System System.out 1 return; {
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        } long n = 1; n 1 long ans = 0; ans 0 while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          } true {
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          } if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            } h > 1 h 1 {
              ans+=n;
              n = n*2;
              h = h/2;
            } ans+=n ans n n = n*2 n n*2 n 2 h = h/2 h h/2 h 2 {
              ans+=n;
              break;
            } ans+=n ans n break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	}
} public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	}
} Main
import java.util.*;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	}
}