#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;

int main(){
    cin >> n;

    int cou = log2(n);
    if((int)log2(n + 1) > cou){
        cou ++;
    }

    cout << cou << endl;
}
