import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); long d = sc.nextLong(); long left = 0; long right = d; while (right - left > 1) { long m = (left + right) / 2; long x = m; long sum = 0; while (x > 0) { sum += x; x /= 2; } if (sum >= d) { right = m; } else { left = m; } } long sum = 0; long x = right; while (x > 0 && sum < d) { sum += x; x /= 2; } if (sum == d) { System.out.println(right); } else { System.out.println(d); } } }