import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); scan.close(); int t = 1; int cnt = 0; if(N == 1) { System.out.println(0); System.exit(0); } while(t < N) { t *= 2; cnt++; } int a = t - N; int ans = a + cnt; System.out.println(ans); } }