import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    } main {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long val = log2(n); val log2(n) log2 n long dd = (long) Math.pow(2, val+1); dd (long) Math.pow(2, val+1) Math.pow Math 2 val+1 val 1 System.out.println((long) dd-1) System.out.println System.out System System.out (long) dd-1 (long) dd 1 String[] args args public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    } log2 {
        return (int) (Math.log(x) / Math.log(2));
    } return (int) (Math.log(x) / Math.log(2)); (int) (Math.log(x) / Math.log(2)) Math.log(x) Math.log Math x Math.log(2) Math.log Math 2 long x x public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long val = log2(n);
        long dd = (long) Math.pow(2, val+1);
        System.out.println((long) dd-1);
    }


    public static int log2(long x) {
        return (int) (Math.log(x) / Math.log(2));
    }
}