import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    }

    static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    }

    static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    }
} Main public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    } main {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    } try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        } {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc int cnt = 1; cnt 1 while (h/2 >= 1) {
                cnt++;
                h = h/2;
            } h/2 >= 1 h/2 h 2 1 {
                cnt++;
                h = h/2;
            } cnt++ cnt h = h/2 h h/2 h 2 long result = calc(cnt) - 1; result calc(cnt) - 1 calc(cnt) calc cnt 1 System.out.println(result) System.out.println System.out System System.out result String[] args args static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    } calc {
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    } if(n == 0){
            return 1;
          } n == 0 n 0 {
            return 1;
          } return 1; 1 return 2 * calc(n-1); 2 * calc(n-1) 2 calc(n-1) calc n-1 n 1 int n n public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    }

    static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    }

    static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    }

    static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    }
}