import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  }
} import java.util.*; util.* java public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  }
} Main public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  } main {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  } Scanner ob=new Scanner(System.in); ob new Scanner(System.in) long h=ob.nextLong(); h ob.nextLong() ob.nextLong ob long k=1; k 1 long c=0; c 0 while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    } h>0 h 0 {
      c=c+k;
      h=h/2;
      k=k*2;
    } c=c+k c c+k c k h=h/2 h h/2 h 2 k=k*2 k k*2 k 2 System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  }
} public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  }
} Main
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    long h=ob.nextLong();
    long k=1;
    long c=0;
    while(h>0)
    {
      c=c+k;
      h=h/2;
      k=k*2;
    }
    System.out.println(c);
  }
}