import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  }
  
  public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
}
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  }
  
  public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
}
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  } main {
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) System.out.println(calc(sc.nextLong(),2)-1) System.out.println System.out System System.out calc(sc.nextLong(),2)-1 calc(sc.nextLong(),2) calc sc.nextLong() sc.nextLong sc 2 1 String[] args args public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
} calc {
    return x == 1 ? sum : calc(x/2,sum * 2);
} return x == 1 ? sum : calc(x/2,sum * 2); x == 1 ? sum : calc(x/2,sum * 2) x == 1 x 1 sum calc(x/2,sum * 2) calc x/2 x 2 sum * 2 sum 2 long x x long sum sum public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  }
  
  public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
}
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  }
  
  public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
}
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  }
  
  public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
}
}