import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  }
} 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 sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  } main {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc int sum = 1; sum 1 while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    } H>1 H 1 {
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    } if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      } H%2 ==0 H%2 H 2 0 {
        H = H/2;
      } H = H/2 H H/2 H 2 {
        H = (H-1)/2;
      } H = (H-1)/2 H (H-1)/2 (H-1) H 1 2 sum ++ sum long total =0; total 0 for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    } int i = 0; int i = 0; i 0 i < sum i sum i++ i++ i {
      total = total + (long)Math.pow(2, i);
    } {
      total = total + (long)Math.pow(2, i);
    } total = total + (long)Math.pow(2, i) total total + (long)Math.pow(2, i) total (long)Math.pow(2, i) Math.pow Math 2 i System.out.println(total) System.out.println System.out System System.out total return; String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    int sum = 1;
    while(H>1){
      if(H%2 ==0){
        H = H/2;
      }else{
        H = (H-1)/2;
      }
        sum ++; 
    }
    long total =0;
    for(int i = 0; i < sum; i++){
      total = total + (long)Math.pow(2, i);
    }
    System.out.println(total);
    return;
  }
}
