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