import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;

        while (H > 1) {
            H /= 2;
            count++;
        }
        // System.out.println("count: " + count);

        long node = 0;
        for (int i = 1; i <= count; i++) {
            node += Math.pow(2,i);
        }

        System.out.println(node+1);
    }
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;

        while (H > 1) {
            H /= 2;
            count++;
        }
        // System.out.println("count: " + count);

        long node = 0;
        for (int i = 1; i <= count; i++) {
            node += Math.pow(2,i);
        }

        System.out.println(node+1);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;

        while (H > 1) {
            H /= 2;
            count++;
        }
        // System.out.println("count: " + count);

        long node = 0;
        for (int i = 1; i <= count; i++) {
            node += Math.pow(2,i);
        }

        System.out.println(node+1);
    } main {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;

        while (H > 1) {
            H /= 2;
            count++;
        }
        // System.out.println("count: " + count);

        long node = 0;
        for (int i = 1; i <= count; i++) {
            node += Math.pow(2,i);
        }

        System.out.println(node+1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long count = 0; count 0 while (H > 1) {
            H /= 2;
            count++;
        } H > 1 H 1 {
            H /= 2;
            count++;
        } H /= 2 H 2 count++ count long node = 0; node 0 for (int i = 1; i <= count; i++) {
            node += Math.pow(2,i);
        } int i = 1; int i = 1; i 1 i <= count i count i++ i++ i {
            node += Math.pow(2,i);
        } {
            node += Math.pow(2,i);
        } node += Math.pow(2,i) node Math.pow(2,i) Math.pow Math 2 i System.out.println(node+1) System.out.println System.out System System.out node+1 node 1 String[] args args
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long count = 0;

        while (H > 1) {
            H /= 2;
            count++;
        }
        // System.out.println("count: " + count);

        long node = 0;
        for (int i = 1; i <= count; i++) {
            node += Math.pow(2,i);
        }

        System.out.println(node+1);
    }
}