import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	}
} import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Collections; Collections java.util public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	}
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	} main {
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<Integer> list = new ArrayList<>(); list new ArrayList<>() long hp = sc.nextLong(); hp sc.nextLong() sc.nextLong sc long count = 1; count 1 long at_count = 0; at_count 0 while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        } hp > 0 hp 0 {
            hp = hp/2;
            at_count += count;
            count = count*2;
        } hp = hp/2 hp hp/2 hp 2 at_count += count at_count count count = count*2 count count*2 count 2 System.out.println(at_count) System.out.println System.out System System.out at_count String[] args args public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	}
} public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	}
} Main
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        long hp = sc.nextLong();

        long count = 1;
        long at_count = 0;

        while(hp > 0){
            hp = hp/2;
            at_count += count;
            count = count*2;
        }
        System.out.println(at_count);
    
	}
}