import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 } main {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double ans = 1; ans 1 double now = 1; now 1 double nowmax = Math.pow(2,now) -1; nowmax Math.pow(2,now) -1 Math.pow(2,now) Math.pow Math 2 now 1 while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        } h >  nowmax h nowmax {
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        } ans += Math.pow(2,now) ans Math.pow(2,now) Math.pow Math 2 now now += 1 now 1 nowmax = Math.pow(2,now) -1 nowmax Math.pow(2,now) -1 Math.pow(2,now) Math.pow Math 2 now 1 System.out.println((long)ans) System.out.println System.out System System.out (long)ans String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        double h = sc.nextDouble();
        double ans = 1;
        double now = 1;
        double nowmax = Math.pow(2,now) -1;
     	while(h >  nowmax){
          ans += Math.pow(2,now);
          now += 1;
          nowmax = Math.pow(2,now) -1;
        }
      System.out.println((long)ans);
 }
}