p178.ans1
======================
1

=================
p178.ans2
======================
2

=================
p178.ans3
======================
0

=================
p178.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int64_t n;

void read() { cin >> n; }

void solve() {
    // With b broken links we get b single loose links plus b + 1 intact
    // segments. The b loose links can make change for any value 1..b directly,
    // and the segments (chosen with the classic 1, 2, 4, ..., 2^b sizes) let us
    // cover everything up to (b + 1) * 2^b - 1 days, where the -1 accounts for
    // the loose links being part of the total. So we find the smallest b with
    // (b + 1) * 2^b - 1 >= n by incrementing b while the bound is still below.

    int64_t x = 2, ans = 0;
    while(x * (ans + 1) - 1 < n) {
        ans++;
        x *= 2;
    }

    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
p178.in1
======================
5

=================
p178.in2
======================
9

=================
p178.in3
======================
1

=================
statement.txt
======================
178. Golden chain
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard
output: standard



Peter arrived to the city and stayed in the hotel. He has no money but few day's later (maximum N days) he will receive a lot of money. And so he has a golden chain with N links. Peter must pay one link everyday, but he can pay more and take change by some of his links paid before.
When he receives money he will get his chain out of pawn. Peter likes his chain and he wants to break minimal number of links. Help him!
For example, if N=5, he must break one link (the second). After it his chain will consist of 3 parts with lengths 1, 1 and 3.
At the first day he will pay one link, at the second - one link too. Now he have one part consists of three connected links. At the third day he will pay 3-linked part and take two separated links (as change) back. On the fourth and fifth day he will pay one link.
You may assume that Peter can choose the way to get change.

Input
Input contains one integer number N (1<=N<=10^16).

Output
In output file you must write one integer number (number of the broken links).

Sample test(s)

Input
9

Output
2
Author:	Vasiliy Astakhov
Resource:	Saratov ST team Spring Contest #1
Date:	18.05.2003







=================
