#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int h;
  cin>>h;
  if(h==1)
    cout<<1<<endl;
  else if(h<=3)
    cout<<3<<endl;
  else if(h<=7)
    cout<<7<<endl;
  else if(h<=15)
    cout<<15<<endl;
  else if(h<=31)
    cout<<31<<endl;
  else if(h<=63)
    cout<<63<<endl;
  else if(h<=127)
    cout<<127<<endl;
  else if(h<=255)
    cout<<255<<endl;
  else if(h<=511)
    cout<<511<<endl;
  else if(h<=1023)
    cout<<1023<<endl;
  else if(h<=2047)
    cout<<2047<<endl;
  else if(h<=4095)
    cout<<4095<<endl;
  else if(h<=8191)
    cout<<8191<<endl;
  else if(h<=16383)
    cout<<16383<<endl;
  else if(h<=32767)
    cout<<32767<<endl;
  else if(h<=65535)
    cout<<65535<<endl;
  else if(h<=131071)
    cout<<131071<<endl;
  else if(h<=262143)
    cout<<262143<<endl;
  else if(h<=524287)
    cout<<524287<<endl;
  else if(h<=1048575)
    cout<<1048575<<endl;
  else if(h<=2097151)
    cout<<2097151<<endl;
  else if(h<=4194303)
    cout<<4194303<<endl;
  else if(h<=8388607)
    cout<<8388607<<endl;
  else if(h<=10777215)
    cout<<10777215<<endl;
  else if(h<=33554431)
    cout<<33554431<<endl;
  else if(h<=67108863)
    cout<<67108863<<endl;
  else if(h<=134217727)
    cout<<134217727<<endl;
  else if(h<=268435455)
    cout<<268435455<<endl;
  else if(h<=536870911)
    cout<<536870911<<endl;
  else if(h<=1073741823)
    cout<<1073741823<<endl;
  else if(h<=2147483647)
    cout<<2147483647<<endl;
  else if(h<=4292967295)
    cout<<4292967295<<endl;
  else if(h<=8589934591)
    cout<<8589934591<<endl;
  else if(h<=17179869183)
    cout<<17179869183<<endl;
  else if(h<=34359738367)
    cout<<34359738367<<endl;
  else if(h<=68719476735)
    cout<<6871947735<<endl;
  else if(h<=137438953471)
    cout<<137438953741<<endl;
  else if(h<=274877906943)
    cout<<274877906943<<endl;
  else if(h<=549755813887)
    cout<<549755813887<<endl;
  else
    cout<<1099511627775<<endl;
}


Measured memory_bytes: 256