import java.util.*;
import java.math.*;

public class Main{
  public static long m_pow(long a, long n) {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  }
} import java.util.*; util.* java import java.math.*; math.* java public class Main{
  public static long m_pow(long a, long n) {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  }
} Main public static long m_pow(long a, long n) {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  } m_pow {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  } long ans = 1; ans 1 while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    } n >= 1 n 1 {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    } if((n & 1) == 1) {
        ans = ans * a;
      } (n & 1) == 1 (n & 1) n 1 1 {
        ans = ans * a;
      } ans = ans * a ans ans * a ans a a = a * a a a * a a a n >>= 1 n 1 return ans; ans long a a long n n public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  } main {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc double cmp = Math.log(H) / Math.log(2); cmp Math.log(H) / Math.log(2) Math.log(H) Math.log Math H Math.log(2) Math.log Math 2 int count = (int) cmp; count (int) cmp System.out.println(m_pow(2, count + 1) - 1) System.out.println System.out System System.out m_pow(2, count + 1) - 1 m_pow(2, count + 1) m_pow 2 count + 1 count 1 1 String[] args args public class Main{
  public static long m_pow(long a, long n) {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  }
} public class Main{
  public static long m_pow(long a, long n) {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  }
} Main
import java.util.*;
import java.math.*;

public class Main{
  public static long m_pow(long a, long n) {
    long ans = 1;
    while(n >= 1) {
      if((n & 1) == 1) {
        ans = ans * a;
      }
      a = a * a;
      n >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
   	double cmp = Math.log(H) / Math.log(2);
    int count = (int) cmp;
    System.out.println(m_pow(2, count + 1) - 1);
  }
}