/* package codechef; // don't place package name! */

import javax.swing.*;
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    }
} import javax.swing.*; swing.* javax import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    }
} Main public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    } main {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) long H = s.nextLong(); H s.nextLong() s.nextLong s long count = 0; count 0 int i=0; i 0 while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        } H>0 H 0 {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        } H/=2 H 2 count+=Math.pow(2,i) count Math.pow(2,i) Math.pow Math 2 i i++ i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    }
} public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    }
} Main
/* package codechef; // don't place package name! */

import javax.swing.*;
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        long count = 0;
        int i=0;
        while(H>0)
        {
            H/=2;
            count+=Math.pow(2,i);
            i++;
        }
        System.out.println(count);
    }
}
