import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    long monster = 1;
    long count = 0;
    while(H > 0){
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    }
    System.out.println(count);
  }
}
 import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    long monster = 1;
    long count = 0;
    while(H > 0){
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    }
    System.out.println(count);
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    long monster = 1;
    long count = 0;
    while(H > 0){
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    }
    System.out.println(count);
  } main {
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    long monster = 1;
    long count = 0;
    while(H > 0){
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    }
    System.out.println(count);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long H = scan.nextLong(); H scan.nextLong() scan.nextLong scan long monster = 1; monster 1 long count = 0; count 0 while(H > 0){
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    } H > 0 H 0 {
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    } count += monster count monster monster = 2 * monster monster 2 * monster 2 monster H = H / 2 H H / 2 H 2 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long H = scan.nextLong();
    long monster = 1;
    long count = 0;
    while(H > 0){
    count += monster;
    monster = 2 * monster;
    H = H / 2;
    }
    System.out.println(count);
  }
}

