import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    } main {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String line = scanner.nextLine(); line scanner.nextLine() scanner.nextLine scanner String[] values = line.split(" "); values line.split(" ") line.split line " " long N = Long.parseLong(values[0]); N Long.parseLong(values[0]) Long.parseLong Long values[0] values 0 if (N == 1) {
            System.out.println("1");
            return;
        } N == 1 N 1 {
            System.out.println("1");
            return;
        } System.out.println("1") System.out.println System.out System System.out "1" return; long temp = N; temp N long atks = 0; atks 0 long n = 0; n 0 while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        } temp >= 1 temp 1 {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        } temp = temp / 2 temp temp / 2 temp 2 n += Math.pow(2,atks) n Math.pow(2,atks) Math.pow Math 2 atks atks ++ atks System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long N = Long.parseLong(values[0]);
        if (N == 1) {
            System.out.println("1");
            return;
        }
        long temp = N;
        long atks = 0;
        long n = 0;
        while (temp >= 1) {
            temp = temp / 2;
            n += Math.pow(2,atks);
            atks ++;
        }
        System.out.println(n);
    }
}