import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long sum = 1; sum 1 long rank = 1; rank 1 while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        } h > 1 h 1 {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        } sum += Math.pow(2, rank) sum Math.pow(2, rank) Math.pow Math 2 rank h = h/2 h h/2 h 2 rank++ rank System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    }
}