#include using namespace std; int main() { long n, x = 1, cnt = 0; scanf("%ld", &n); while (x < n) { x *= 2; cnt++; } while (x != n) { x--; cnt++; } printf("%ld\n", cnt); return 0; }