import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  }
} 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 n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  }
} Main public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  } main {

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc int n = 1; n 1 long result = 0; result 0 while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    } true {
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    } result = (long) Math.pow(2,n) result (long) Math.pow(2,n) Math.pow Math 2 n if(result > H){break;} result > H result H {break;} break; n++ n long s = (long) Math.pow(2,n) - 1; s (long) Math.pow(2,n) - 1 (long) Math.pow(2,n) Math.pow Math 2 n 1 System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  }
} public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  }
}