#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define repp(i, n, m) for (int i = m; i < int(n); ++i)

//alias g++='g++ -I/mnt/c/Users/Owner/Desktop/ac-library'
using ll             = long long;
using ld             = long double;
using P              = pair<int, int>;
using PI             = pair<pair<int, int>, int>;
using PL             = pair<long long, long long>;
using PLL            = pair<pair<long long, long long>, long long>;
using Pxy            = pair<long double, long double>;
const int INF        = 1001001007;
const int modd       = 1000000007;
const long long modl = 1000000007LL;
const long long mod  = 998244353LL;
const ll inf         = 2e18;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yn(bool t) {
    if (t)
        yes();
    else
        no();
}
void Yes() { cout << "YES" << endl; }
void No() { cout << "NO" << endl; }
void YN(bool t) {
    if (t)
        Yes();
    else
        No();
}

vector<int> dx   = { 0, 1, 0, -1 };
vector<int> dy   = { 1, 0, -1, 0 };
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string alp = "abcdefghijklmnopqrstuvwxyz";

int main() {
    string S;
    cin >> S;
    deque<char> T;
    bool flag = false;

    for (char s : S) {
        if (s == 'R') {
            flag = flag ? false : true;
        } else {
            if (flag)  T.push_front(s);
            else  T.push_back(s);
        }
    }
    if (flag == true) reverse(T.begin(), T.end());
    string U;
    rep(i,T.size()){
        if(U.size() && T[i]==U.back()){
            U.pop_back();
        }
        else U.push_back(T[i]);
    }
    
    cout << U << endl;
}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")   
#pragma GCC optimize ("trapv") 

 
#include<bits/stdc++.h>  
#define ll long long  
#define ff first  
#define ss second  
#define mkp make_pair 
#define pb push_back  
#define pf push_front  
#define inf 1000000000
#define maxn 300005
#define mod  100000000
#define mod1 1000000009 
  
using namespace std;  



void solve(){     

  ll n;  

  cin>>n;  
  

  ll ans_=LONG_LONG_MAX; 


  for(int i=0;i<60;++i){ 
     
     ll t=(1LL<<i); 
     
     ll c=n%t; 

     ll a=(n/t); 

     ans_=min(ans_,a+c+i);

  } 

  cout<<ans_<<'\n';




}


int main(){ 

  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);   
  


  #ifndef ONLINE_JUDGE  

       freopen("input.txt","r",stdin);  
       freopen("output.txt","w",stdout); 
 
  #endif 
        
        // int t; 
        // cin>>t; 
        // while(t--)
        solve(); 
 
     
return 0;  
 
}    




