import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    }
} import java.util.*; util.* java public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    }
} Main public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    } main {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) long o=0; o 0 long h=sc.nextLong(); h sc.nextLong() sc.nextLong sc long c=1; c 1 while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        } h>=1 h 1 {
            o+=c;
            c*=2;
            h/=2;
        } o+=c o c c*=2 c 2 h/=2 h 2 System.out.println(o) System.out.println System.out System System.out o String[] args args public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    }
} public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    }
} Main
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long o=0;
        long h=sc.nextLong();
        long c=1;
        while(h>=1){
            o+=c;
            c*=2;
            h/=2;
        }
       //PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
      
      
      System.out.println(o);
    }
}