import java.util.*;
import java.io.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    System.out.println(ans);
  }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    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 String two_bit = Long.toBinaryString(h); two_bit Long.toBinaryString(h) Long.toBinaryString Long h long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1; ans (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1 (long)Math.pow(2.0, (double)two_bit.length()) Math.pow Math 2.0 (double)two_bit.length() two_bit.length two_bit (long) 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    System.out.println(ans);
  }
} Main
import java.util.*;
import java.io.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    String two_bit = Long.toBinaryString(h);
    long ans = (long)Math.pow(2.0, (double)two_bit.length()) - (long) 1;
    System.out.println(ans);
  }
}