#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  long long m;
  cin>>m;
  const Int n = 128;
  Int x=1;
  for(Int i=0;i<n;i++){
    x=x+x;
    x%=m;
  }
  cout<<x<<endl;
  return 0;
}