#include int main(void) { long int N; int num = 1; int sum; int count=0; scanf("%ld", &N); while (N >= num * 2) { num *= 2; count++; } sum = num; for (; N - sum > 0; num--) { while (N - (sum + num * 2) >= 0) { sum += num * 2; count++; } } printf("%d", count); }