import java.util.Scanner;
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	}
	
} import java.util.Scanner; Scanner java.util import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	}
	
} Main public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	} main {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	} try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        } {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        } Scanner scn = new Scanner(System.in) Scanner scn = new Scanner(System.in) new Scanner(System.in) long h = scn.nextLong(); h scn.nextLong() scn.nextLong scn long tekicount = 1; tekicount 1 long total = h; total h while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            } true {
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            } if(h == 1){
                 tekicount = tekicount *2;
                    break;
                } h == 1 h 1 {
                 tekicount = tekicount *2;
                    break;
                } tekicount = tekicount *2 tekicount tekicount *2 tekicount 2 break; h = h/2 h h/2 h 2 tekicount = tekicount*2 tekicount tekicount*2 tekicount 2 total = tekicount - 1 total tekicount - 1 tekicount 1 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
	public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	}
	
} public class Main {
	public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	}
	
} Main
import java.util.Scanner;
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	}
	
}
