import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} Main public static void main(String[] args) {
        new Main();
    } main {
        new Main();
    } new Main() String[] args args public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    } Main {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = Long.parseLong(sc.next()); H Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc int exp = (int) Math.floor(Math.log(H) / Math.log(2)); exp (int) Math.floor(Math.log(H) / Math.log(2)) Math.floor Math Math.log(H) / Math.log(2) Math.log(H) Math.log Math H Math.log(2) Math.log Math 2 long result = 0; result 0 for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        } int i = 0; int i = 0; i 0 i <= exp i exp i++ i++ i {
            result += Math.pow(2, i);
        } {
            result += Math.pow(2, i);
        } result += Math.pow(2, i) result Math.pow(2, i) Math.pow Math 2 i System.out.println(result) System.out.println System.out System System.out result public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main();
    }

    public Main() {
        Scanner sc = new Scanner(System.in);
        long H = Long.parseLong(sc.next());
        int exp = (int) Math.floor(Math.log(H) / Math.log(2));
        long result = 0;
        for (int i = 0; i <= exp; i++) {
            result += Math.pow(2, i);
        }
        System.out.println(result);
    }
}
