import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  }

  static long fast(long i){
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  }

  static long fast(long i){
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  } main {
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long n = scan.nextLong(); n scan.nextLong() scan.nextLong scan long count = 0; count 0 while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    } true {
      if (fast(count) > n){
        break;
      }
      count += 1;
    } if (fast(count) > n){
        break;
      } fast(count) > n fast(count) fast count n {
        break;
      } break; count += 1 count 1 System.out.println(fast(count)-1) System.out.println System.out System System.out fast(count)-1 fast(count) fast count 1 String[] args args static long fast(long i){
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  } fast {
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  } long ret = 1; ret 1 long base = 2; base 2 while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    } i>0 i 0 {
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    } if ((i & 1) == 1){
        ret *= base;
      } (i & 1) == 1 (i & 1) i 1 1 {
        ret *= base;
      } ret *= base ret base base = base*base base base*base base base i >>= 1 i 1 return ret; ret long i i public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  }

  static long fast(long i){
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  }

  static long fast(long i){
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long count = 0;
    while (true){
      if (fast(count) > n){
        break;
      }
      count += 1;
    }
    System.out.println(fast(count)-1);
  }

  static long fast(long i){
    long ret = 1;
    long base = 2;
    while (i>0){
      if ((i & 1) == 1){
        ret *= base;
      }
      base = base*base;
      i >>= 1;
    }
    return ret;
  }
}
