import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long normal = 0; long score = N; for(int i = 0; i < 61; i++) { if(score > 0) { normal += score; score /= 2; } else { break; } } long skill = 0; for(int i = 0; i < 61; i++) { score = N; long a = 0; for(int j = 0; j < i; j++) { a += score; score /= 2; } a += (2 * score); skill = Math.max(skill, a); } System.out.println(skill - normal); } }