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