import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  }
}
     import java.util.*; util.* java public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  }
} Main public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  } main {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long t = (long)Math.floor(Math.log(2*n)/Math.log(2)); t (long)Math.floor(Math.log(2*n)/Math.log(2)) Math.floor Math Math.log(2*n)/Math.log(2) Math.log(2*n) Math.log Math 2*n 2 n Math.log(2) Math.log Math 2 t = (long)Math.pow(2,t) t (long)Math.pow(2,t) Math.pow Math 2 t System.out.println(t-1) System.out.println System.out System System.out t-1 t 1 String args[] args public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  }
} public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  }
} Main
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long t = (long)Math.floor(Math.log(2*n)/Math.log(2));
    t = (long)Math.pow(2,t);
    System.out.println(t-1);
  }
}
    
