import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N = Long.parseLong(sc.next()); N Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc int count = 0; count 0 long x = N; x N long res = 0; res 0 while(x != 0){
            x /= 2;
            count++;
        } x != 0 x 0 {
            x /= 2;
            count++;
        } x /= 2 x 2 count++ count for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        } int i=0; int i=0; i 0 i<count i count i++ i++ i {
            res += (long)Math.pow(2,i);
        } {
            res += (long)Math.pow(2,i);
        } res += (long)Math.pow(2,i) res (long)Math.pow(2,i) Math.pow Math 2 i System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        int count = 0;
        long x = N;
        long res = 0;
        while(x != 0){
            x /= 2;
            count++;
        }
        for(int i=0;i<count;i++){
            res += (long)Math.pow(2,i);
        }
        System.out.println(res);
    }
}